Injects the event loop of the bot's client into the plugin if it implements
\Phergie\Irc\Bot\React\LoopInterface.

@param \Phergie\Irc\Bot\React\PluginInterface $plugin Loaded plugin
@param \Phergie\Irc\Bot\React\Bot $bot Bot that loaded the plugin
548688
public function process(PluginInterface $plugin, Bot $bot)
    {
        $client = $bot->getClient();
        if ($plugin instanceof LoopAwareInterface
            && $client instanceof LoopAccessorInterface) {
            $plugin->setLoop($client->getLoop());
        }
    }
564161
public function registerPlugin(Plugin $plugin)
    {
        try {
            $this->smarty->registerPlugin($plugin->getType(), $plugin->getName(), $plugin->getCallbackFunction(),
                $plugin->getAttribute('Cachable', true), $plugin->getAttribute('CacheAttr', null));
        } catch (\SmartyException $e) {
            throw new SmartyException($e);
        }
    }
892457
public function addPlugin(PluginInterface $plugin)
    {
        if ($this->io->isDebug()) {
            $this->io->writeError('Loading plugin '.get_class($plugin));
        }
        $this->plugins[] =  $plugin;
        $plugin->activate($this->composer, $this->io);

        if ($plugin instanceof EventSubscriberInterface) {
            $this->composer->getEventDispatcher()->addSubscriber($plugin);
        }
    }
1025320
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->startCommand($output);
        $plugins = $this
            ->pluginManager
            ->loadPlugins();

        foreach ($plugins as $plugin) {
            $this->printMessage(
                $output,
                'Plugin',
                'Plugin "' . $plugin->getNamespace() . '" installed'
            );
        }

        $this->finishCommand($output);
    }
406673
protected function getPluginMetas(PluginInterface $plugin)
    {
        $metas = $plugin->getMetas();

        if (is_array($metas) === false) {
            $classname = get_class($plugin);

            throw new \RuntimeException(sprintf('Expected an array at method "getMetas" of the plugin: "%s".', $classname));
        }

        $metas = $this->resolver->resolve($metas);

        if (empty($metas['name']) === true) {
            $metas['name'] = get_class($plugin);
        }

        return $metas;
    }
938597
public function setClient(ClientInterface $client)
    {
        parent::setClient($client);
        foreach ($this->plugins as $plugin) {
            if (!($plugin instanceof ClientAwareInterface)) {
                continue;
            }

            $plugin->setClient($client);
        }
    }
718459
public function invokePluginHook($hookName)
	{
		$args = func_get_args();
		array_shift($args);

		foreach($this->plugins as $plugin) {
			if(method_exists($plugin, $hookName) === false)
				continue;

			call_user_func_array(array($plugin, $hookName), $args);
		}
	}
609811
public function appendPlugin(Plugin ...$plugin): HttpClientConfigurator
    {
        foreach ($plugin as $p) {
            $this->appendPlugins[] = $p;
        }

        return $this;
    }
663731
public function validatePlugin($plugin)
    {
        //bug fix: not all plugin implements the ViewHelperInterface
        //eg: PaginationControl, but it has the setView method so it's ok to inject
        if ($plugin instanceof ViewHelperInterface || method_exists($plugin, 'setView')) {
            // we're okay
            return;
        }

        throw new Exception\RuntimeException(sprintf(
            'Plugin of type %s is invalid; must implement Zend_View_Helper_Interface',
            (is_object($plugin) ? get_class($plugin) : gettype($plugin))
        ));
    }
878550
private function createPluginChain(array $pluginList, callable $clientCallable): callable
    {
        $firstCallable = $lastCallable = $clientCallable;

        while ($plugin = array_pop($pluginList)) {
            $lastCallable = function (RequestInterface $request) use ($plugin, $lastCallable, &$firstCallable) {
                return $plugin->handleRequest($request, $lastCallable, $firstCallable);
            };

            $firstCallable = $lastCallable;
        }

        $firstCalls = 0;
        $firstCallable = function (RequestInterface $request) use ($lastCallable, &$firstCalls) {
            if ($firstCalls > $this->options['max_restarts']) {
                throw new LoopException('Too many restarts in plugin client', $request);
            }

            ++$firstCalls;

            return $lastCallable($request);
        };

        return $firstCallable;
    }
1241663
public static function registerApplicationPlugin(ApplicationPlugin $plugin, $priority = self::PRIORITY_NORMAL)
    {
        if ($priority != self::PRIORITY_HIGH 
                && $priority != self::PRIORITY_NORMAL 
                && $priority != self::PRIORITY_LOW) {
            throw new ArchException('Bad plugin priority');
        }
        $pluginClass = get_class($plugin);
        if (isset(self::$plugins[$pluginClass])) {
            throw new ArchException('Plugin ' . $pluginClass . ' already registered');
        }
        self::$plugins[$pluginClass] = $plugin;
        self::$pluginsOrder[$priority][] = $pluginClass;
    }
683236
synchronized Plugin nextPlugin() {
    	if (!init) {
    		this.reset();
    	}
    	
        Plugin plugin = probeNextPlugin();
        if (plugin == null) {
            return null;
        }
        
        listPending.remove(plugin);
        plugin.setTimeStarted();
        listRunning.add(plugin);

        return plugin;
    }
118427
private function registerGuzzlePlugin(Definition $clientDefinition, array $plugins)
    {
        foreach ($plugins as $pluginId => $attributes) {
            $clientDefinition->addMethodCall(
                'addSubscriber',
                array(new Reference($pluginId))
            );
        }
    }
94972
public function registerPlugin($plugin)
    {
        /** @var AnaloguePluginInterface $plugin */
        $plugin = new $plugin($this);

        $this->events = array_merge($this->events, $plugin->getCustomEvents());

        $plugin->register();
    }
296138
def execute_plugin(method)
      Polipus::Plugin.plugins.each do |k, p|
        next unless p.respond_to?(method)
        @logger.info { "Running plugin method #{method} on #{k}" }
        ret_val = p.send(method, self)
        instance_eval(&ret_val) if ret_val.is_a? Proc
      end
    end
64407
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $io = new SymfonyStyle($input, $output);
        $context = Context::createDefaultContext();
        $plugins = $this->prepareExecution(self::LIFECYCLE_METHOD, $io, $input, $context);

        $installedPluginCount = 0;
        /** @var PluginEntity $plugin */
        foreach ($plugins as $plugin) {
            if ($input->getOption('reinstall') && $plugin->getInstalledAt()) {
                $this->pluginLifecycleService->uninstallPlugin($plugin, $context);
            }

            if ($input->getOption('activate') && $plugin->getInstalledAt() && $plugin->getActive() === false) {
                $io->note(sprintf('Plugin "%s" is already installed. Activating.', $plugin->getName()));
                $this->pluginLifecycleService->activatePlugin($plugin, $context);

                continue;
            }

            if ($plugin->getInstalledAt()) {
                $io->note(sprintf('Plugin "%s" is already installed. Skipping.', $plugin->getName()));

                continue;
            }

            $activationSuffix = '';
            $message = 'Plugin "%s" has been installed%s successfully.';

            $this->pluginLifecycleService->installPlugin($plugin, $context);
            ++$installedPluginCount;

            if ($input->getOption('activate')) {
                $this->pluginLifecycleService->activatePlugin($plugin, $context);
                $activationSuffix = ' and activated';
            }

            $io->text(sprintf($message, $plugin->getName(), $activationSuffix));
        }

        if ($installedPluginCount !== 0) {
            $io->success(sprintf('Installed %d plugin(s).', $installedPluginCount));
        }
    }
446856
public function registerPlugin(Swift_Events_EventListener $plugin)
    {
        foreach ($this->transports as $transport) {
            $transport->registerPlugin($plugin);
        }
    }