diff options
-rw-r--r-- | core/WidgetsList.php | 14 | ||||
-rw-r--r-- | plugins/ExamplePlugin/Widgets.php | 2 |
2 files changed, 11 insertions, 5 deletions
diff --git a/core/WidgetsList.php b/core/WidgetsList.php index 75c75937d8..095c54cfd7 100644 --- a/core/WidgetsList.php +++ b/core/WidgetsList.php @@ -26,7 +26,7 @@ class WidgetsList extends Singleton * * @var array */ - static protected $widgets = null; + static protected $widgets = array(); /** * Indicates whether the hook was posted or not @@ -80,10 +80,11 @@ class WidgetsList extends Singleton Piwik::postEvent('WidgetsList.addWidgets'); /** @var \Piwik\Plugin\Widgets[] $widgets */ - $widgets = PluginManager::getInstance()->findComponents('Widgets', 'Piwik\\Plugin\\Widgets'); + $widgets = PluginManager::getInstance()->findComponents('Widgets', 'Piwik\\Plugin\\Widgets'); + $widgetsList = self::getInstance(); foreach ($widgets as $widget) { - $widget->configure(WidgetsList::getInstance()); + $widget->configure($widgetsList); } } } @@ -145,6 +146,11 @@ class WidgetsList extends Singleton } $widgetUniqueId .= $name . $value; } + + if (!array_key_exists($widgetCategory, self::$widgets)) { + self::$widgets[$widgetCategory] = array(); + } + self::$widgets[$widgetCategory][] = array( 'name' => $widgetName, 'uniqueId' => $widgetUniqueId, @@ -209,7 +215,7 @@ class WidgetsList extends Singleton */ public static function _reset() { - self::$widgets = null; + self::$widgets = array(); self::$hookCalled = false; } } diff --git a/plugins/ExamplePlugin/Widgets.php b/plugins/ExamplePlugin/Widgets.php index 2c99372b9b..6ce0c590dc 100644 --- a/plugins/ExamplePlugin/Widgets.php +++ b/plugins/ExamplePlugin/Widgets.php @@ -6,7 +6,7 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later * */ -namespace Piwik\Plugins\ExampleRssWidget; +namespace Piwik\Plugins\ExamplePlugin; use Piwik\WidgetsList; |