Returns a Plugin object by name.
public getLoadedPlugin ( string $name ) : |
||
$name | string | The name of the plugin, eg, `'Actions'`. |
return |
private function getLoadedAndActivated($pluginName) { if (!$this->pluginManager->isPluginLoaded($pluginName)) { return; } try { if (!$this->pluginManager->isPluginActivated($pluginName)) { return; } $plugin = $this->pluginManager->getLoadedPlugin($pluginName); } catch (\Exception $e) { // we are not allowed to use possible settings from this plugin, plugin is not active return; } return $plugin; }
/** * Get the widget defined by the given module and action. * * @param string $module Aka plugin name, eg 'CoreHome' * @param string $action An action eg 'renderMe' * @return Widget|null * @throws \Exception Throws an exception if the widget is not enabled. */ public function factory($module, $action) { if (empty($module) || empty($action)) { return; } try { if (!$this->pluginManager->isPluginActivated($module)) { return; } $plugin = $this->pluginManager->getLoadedPlugin($module); } catch (\Exception $e) { // we are not allowed to use possible widgets, plugin is not active return; } /** @var Widget[] $widgetContainer */ $widgets = $plugin->findMultipleComponents('Widgets', 'Piwik\\Widget\\Widget'); foreach ($widgets as $widgetClass) { $config = $this->getWidgetConfigForClassName($widgetClass); if ($config->getAction() === $action) { $config->checkIsEnabled(); return StaticContainer::get($widgetClass); } } }