@param \EightPoints\Bundle\GuzzleBundle\EightPointsGuzzleBundlePlugin $plugin

@throws \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException

@return void
174550
protected function registerPlugin(EightPointsGuzzleBundlePlugin $plugin)
    {
        // Check plugins name duplication
        foreach ($this->plugins as $registeredPlugin) {
            if ($registeredPlugin->getPluginName() === $plugin->getPluginName()) {
                throw new InvalidConfigurationException(sprintf(
                    'Trying to connect two plugins with same name: %s',
                    $plugin->getPluginName()
                ));
            }
        }

        $this->plugins[] = $plugin;
    }
853371
private function initializePlugin($pluginId) {

		$configData = $this->config->plugins[$pluginId];

		// load class file

		$class	= str_replace('/', '\\', $configData['class']);
		
		$file	= $this->rootPath . 'src/' . $configData['classPath'] . $class . '.php';

		if(!file_exists($file)) {
			throw new ApplicationException(sprintf("Class file '%s' for plugin '%s' not found.", $file, $pluginId));
		}

		require $file;
		
		// create instance

		$plugin = new $class;
		
		// check whether instance implements SubscriberInterface
		
		if(!$plugin instanceof SubscriberInterface) {
			throw new ApplicationException(sprintf("Plugin '%s' (class %s) does not implement the SubscriberInterface.", $pluginId, $class));
		}
		
		// set parameters
		
		if(!empty($configData['parameters'])) {

			if(!method_exists($plugin, 'setParameters')) {
				throw new ApplicationException(sprintf("Plugin '%s' (class %s) does not provide a 'setParameters' method but has parameters configured.", $pluginId, $class));
			}
			
			$plugin->setParameters($configData['parameters']);
		}

		// register plugin with dispatcher

		EventDispatcher::getInstance()->addSubscriber($plugin);
		
		return $plugin;

	}
1063084
public function unloadPlugin($plugin)
    {
        $this->resetTransientCache();

        if (!($plugin instanceof Plugin)) {
            $oPlugin = $this->loadPlugin($plugin);
            if ($oPlugin === null) {
                unset($this->loadedPlugins[$plugin]);
                return;
            }

            $plugin = $oPlugin;
        }

        unset($this->loadedPlugins[$plugin->getPluginName()]);
    }
511484
public function registerPlugin($pluginId, $pluginService)
    {
        parent::registerPlugin($pluginId, $pluginService);

        $pluginService->setCurrentDataProvider($this);
    }
159277
public function addSiteWidePlugin(PluginInstance $plugin)
    {
        if (!$plugin->isSiteWide()) {
            throw new InvalidArgumentException(
                'Plugin Instance Must be set to Site Wide'
            );
        }

        $displayName = $plugin->getDisplayName();

        if (empty($displayName)) {
            throw new InvalidArgumentException(
                'Plugin Instance Must be set to Site Wide'
            );
        }

        $this->sitePlugins->add($plugin);
    }
769030
public function update(PluginBundle $pluginBundle, array $pluginConfiguration)
    {
        /** @var Plugin $plugin */
        $plugin = $this->em->getRepository('ClarolineCoreBundle:Plugin')->findOneBy(
            array(
                 'vendorName' => $pluginBundle->getVendorName(),
                 'bundleName' => $pluginBundle->getBundleName()
            )
        );

        if (null === $plugin) {
            throw new \Exception('Unable to retrieve plugin for updating its configuration.');
        }

        $plugin->setHasOptions($pluginConfiguration['has_options']);

        $this->em->persist($plugin);
        $this->updateConfiguration($pluginConfiguration, $plugin, $pluginBundle);
        $this->em->flush();
    }
169369
protected function uninstallCMSNavItems(Plugin $plugin)
    {
        $dto = new DTO(array('PluginID' => $plugin->PluginID));
        $navitems = $this->CMSNavItemService->findAll($dto)->getResults();

        rsort($navitems);

        foreach ($navitems as $navitem) {
            $this->CMSNavItemService->delete($navitem->Slug);
        }
    }
1120215
public function setPlugins($plugins)
    {
        $this->plugins = array();
        foreach ($plugins as $key => $plugin) {
            $pluginClass = $plugin;
            if (is_array($plugin)) {
                if (!isset($plugin[Config::KEY_CLASS])) {
                    throw new PluginException('Invalid or missing class for plugin '.$key);
                } elseif (!class_exists($plugin[Config::KEY_CLASS])) {
                    throw new PluginException('Invalid or missing class for plugin '.$key);
                }
                $pluginClass = $plugin[Config::KEY_CLASS];
            }
            $options = array();
            if (isset($plugin[Config::KEY_OPTIONS])) {
                $options = (array)$plugin[Config::KEY_OPTIONS];
            }
            $this->plugins[] = new $pluginClass($options);
        }
        $this->plugins = $this->sortPlugins($this->plugins);
        return $this;
    }
552088
protected function validatePluginEvents(PluginInterface $plugin)
    {
        $events = $plugin->getSubscribedEvents();
        if (!is_array($events)) {
            throw new \RuntimeException(
                'Plugin of class ' . get_class($plugin) .
                    ' has getSubscribedEvents() implementation' .
                    ' that does not return an array'
            );
        }
        foreach ($events as $event => $callback) {
            if (!is_string($event)
                || !is_callable([ $plugin, $callback ])
                && !is_callable($callback)) {
                throw new \RuntimeException(
                    'Plugin of class ' . get_class($plugin) .
                        ' returns non-string event name or invalid callback' .
                        ' for event "' . $event . '"'
                );
            }
        }
    }
974723
public function unregister(PluginBundle $plugin)
    {
        $pluginFqcn = get_class($plugin);
        $this->dbWriter->delete($pluginFqcn);
    }
437858
public function validatePlugin($service)
    {
        if ($service instanceof ServiceInterface) {
            return;
        }

        throw new InvalidPluginException(sprintf(
            'Plugin of type %s is invalid; must implement %s\Service\ServiceInterface',
            (is_object($service) ? get_class($service) : gettype($service)),
            __NAMESPACE__
        ));
    }
609811
public function appendPlugin(Plugin ...$plugin): HttpClientConfigurator
    {
        foreach ($plugin as $p) {
            $this->appendPlugins[] = $p;
        }

        return $this;
    }
137771
public function bootPlugin($plugin)
    {
        if (!$plugin || $plugin->disabled) {
            return;
        }

        if (!self::$noInit || $plugin->elevated) {
            $plugin->boot();
        }
    }
638045
public function addPlugin(PluginInterface $plugin)
    {
        $plugin->onAdd($this); // Called before adding the plugin, because it may throw an exception
        $this->plugins[] = $plugin;
        
        return $this;
    }
499809
private function savePlugin(Plugin $plugin)
    {
        $this
            ->pluginObjectManager
            ->persist($plugin);

        $this
            ->pluginObjectManager
            ->flush($plugin);

        return $this;
    }
15621
private function validatePluginClass($pluginClass)
    {
        if (!class_exists($pluginClass)) {
            throw new InvalidConfigException(sprintf(
                'The plugin class %s does not exist.',
                $pluginClass
            ));
        }

        if (!in_array('Puli\Manager\Api\PuliPlugin', class_implements($pluginClass))) {
            throw new InvalidConfigException(sprintf(
                'The plugin class %s must implement PuliPlugin.',
                $pluginClass
            ));
        }
    }
347816
public function register(PluginBundle $plugin, array $pluginConfiguration)
    {
        $pluginFqcn = get_class($plugin);
        $this->dbWriter->insert($plugin, $pluginConfiguration);
    }