Piwik\Plugin\Manager::loadPlugin PHP Method

loadPlugin() public method

Contrary to loadPlugins() it does not activate the plugin, it only loads it.
public loadPlugin ( string $pluginName ) : Plugin | null
$pluginName string
return Piwik\Plugin | null
    public function loadPlugin($pluginName)
    {
        if (isset($this->loadedPlugins[$pluginName])) {
            return $this->loadedPlugins[$pluginName];
        }
        $newPlugin = $this->makePluginClass($pluginName);
        $this->addLoadedPlugin($pluginName, $newPlugin);
        return $newPlugin;
    }

Usage Example

Ejemplo n.º 1
0
 public function activate($redirectAfter = true)
 {
     $pluginName = $this->initPluginModification(static::ACTIVATE_NONCE);
     $this->dieIfPluginsAdminIsDisabled();
     $this->pluginManager->activatePlugin($pluginName);
     if ($redirectAfter) {
         $message = $this->translator->translate('CorePluginsAdmin_SuccessfullyActicated', array($pluginName));
         if ($this->settingsProvider->getSystemSettings($pluginName)) {
             $target = sprintf('<a href="index.php%s#%s">', Url::getCurrentQueryStringWithParametersModified(array('module' => 'CoreAdminHome', 'action' => 'generalSettings')), $pluginName);
             $message .= ' ' . $this->translator->translate('CorePluginsAdmin_ChangeSettingsPossible', array($target, '</a>'));
         }
         $notification = new Notification($message);
         $notification->raw = true;
         $notification->title = $this->translator->translate('General_WellDone');
         $notification->context = Notification::CONTEXT_SUCCESS;
         Notification\Manager::notify('CorePluginsAdmin_PluginActivated', $notification);
         $redirectTo = Common::getRequestVar('redirectTo', '', 'string');
         if (!empty($redirectTo) && $redirectTo === 'marketplace') {
             $this->redirectToIndex('Marketplace', 'overview');
         } elseif (!empty($redirectTo) && $redirectTo === 'referrer') {
             $this->redirectAfterModification($redirectAfter);
         } else {
             $plugin = $this->pluginManager->loadPlugin($pluginName);
             $actionToRedirect = 'plugins';
             if ($plugin->isTheme()) {
                 $actionToRedirect = 'themes';
             }
             $this->redirectToIndex('CorePluginsAdmin', $actionToRedirect);
         }
     }
 }
Manager