Validates a plugin's event callbacks.

@param \Phergie\Irc\Bot\React\PluginInterface $plugin
@throws \RuntimeException if any event callback is invalid
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 . '"'
                );
            }
        }
    }
157953
public function isReady($plugin)
    {
        $errors = $this->getMissingRequirements($plugin);
        $errorCount = count($errors['extensions'])
            + count($errors['plugins'])
            + count($errors['extras']);

        return 0 === $errorCount;
    }
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;
    }
30472
function validatePlugin(plugin) {
    var packageInfos = plugin.getPackage();

    var isValid = (
        plugin.isLoaded() &&
        packageInfos &&
        packageInfos.get('name') &&
        packageInfos.get('engines') &&
        packageInfos.get('engines').get('gitbook')
    );

    if (!isValid) {
        return Promise.reject(new Error('Error loading plugin "' + plugin.getName() + '" at "' + plugin.getPath() + '"'));
    }

    var engine = packageInfos.get('engines').get('gitbook');
    if (!gitbook.satisfies(engine)) {
        return Promise.reject(new Error('GitBook doesn\'t satisfy the requirements of this plugin: ' + engine));
    }

    return Promise(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()]);
    }
111163
public function validate($instance)
    {
        if ($instance instanceof $this->instanceOf) {
            // we're okay
            return;
        }

        throw new InvalidServiceException(sprintf(
            'Plugin of type %s is invalid; must implement %s',
            (is_object($instance) ? get_class($instance) : gettype($instance)),
            Processor::class
        ));
    }
1041093
public function check(PluginBundle $plugin, $updateMode = false)
    {
        if (!is_file($plugin->getConfigFile())) {
            $error  = new ValidationError('config.yml file missing');
            $errors = array($error);

            return $errors;
        }

        $config = $this->yamlParser->parse(file_get_contents($plugin->getConfigFile()));
        $names = array();
        $listResource = $this->em->getRepository('ClarolineCoreBundle:Resource\ResourceType')->findAll();

        foreach ($listResource as $resource) {
            $names[] = $resource->getName();
        }

        $tools = array();
        /** @var \Claroline\CoreBundle\Entity\Tool\Tool[] $listTool */
        $listTool = $this->em->getRepository('ClarolineCoreBundle:Tool\Tool')->findAllWithPlugin();

        foreach ($listTool as $tool) {
            $toolPlugin = $tool->getPlugin();

            $tools[] = sprintf("%s%s", ($toolPlugin ? $toolPlugin->getBundleFQCN() . '-' : ''), $tool->getName());
        }

        $resourceActions = array();
        $listResourceActions = $this->em->getRepository('ClarolineCoreBundle:Resource\MenuAction')->findBy(array('resourceType' => null, 'isCustom' => true));

        foreach ($listResourceActions as $resourceAction) {
            $resourceActions[] = $resourceAction->getName();
        }

        $widgets = array();
        /** @var \Claroline\CoreBundle\Entity\Widget\Widget[] $listWidget */
        $listWidget = $this->em->getRepository('ClarolineCoreBundle:Widget\Widget')->findAllWithPlugin();

        foreach ($listWidget as $widget) {
            $widgetPlugin = $widget->getPlugin();

            $widgets[] = sprintf("%s%s", ($widgetPlugin ? $widgetPlugin->getBundleFQCN() . '-' : ''), $widget->getName());
        }

        $processor = new Processor();
        $configuration = new Configuration($plugin, $names, $tools, $resourceActions, $widgets);
        $configuration->setUpdateMode($updateMode);

        try {
            $this->processedConfiguration = $processor->processConfiguration($configuration, $config);
        } catch (\Exception $e) {
            $error  = new ValidationError($e->getMessage());

            return array($error);
        }
    }
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__
        ));
    }
966656
public function addPlugin(PluginInterface $plugin)
    {
        $this->plugins[] = $plugin;

        $plugin->activate($this->eventDispatcher);

        if ($plugin instanceof EventSubscriberInterface) {
            $this->eventDispatcher->addSubscriber($plugin);
        }
    }
173100
public function addPlugin(PluginInterface $plugin, $name = null) {
		if ($name === null) {
			$this->plugins[] = $plugin;
			
			return $this;
		}
		
		$this->plugins[$name] = $plugin;
		
		return $this;
	}
276745
public function validatePlugin($plugin)
    {
        if ($plugin instanceof DomainServiceInterface) {
            return; // we're okay
        }

        throw new \InvalidArgumentException(sprintf(
            'Can\'t create domain service for %s; '
                . 'Domain service must implement %s',
            (is_object($plugin) ? get_class($plugin) : gettype($plugin)),
            DomainServiceInterface::class
        ));
    }
1163704
public function update(PluginBundleInterface $plugin)
    {
        $this->validate($plugin, true);

        $this->dbWriter->update($plugin, $this->validator->getPluginConfiguration());
    }
939567
public function getPlugin(string $pluginName): ExtensionPluginInterface
    {
        if (!isset($this->plugins[$pluginName])) {
            throw new RuntimeException(
                sprintf(
                    'Extension plugin "%s" does not exist',
                    $pluginName
                )
            );
        }

        return $this->plugins[$pluginName];
    }
212211
public function validatePlugin($plugin)
    {
        if ($plugin instanceof AbstractPlugin) {
            return; // we're okay
        }

        throw new \InvalidArgumentException(sprintf(
            'Can\'t create jQuery plugin for %s; Plugin must be an instance of %s',
            (is_object($plugin) ? get_class($plugin) : gettype($plugin)),
            AbstractPlugin::class
        ));
    }
885401
public function validatePlugin($plugin)
    {
        if ($plugin instanceof AchievementProviderInterface) {
            return; // we're okay
        }

        throw new RuntimeException(
            sprintf(
                'Plugin of type %s is invalid; must implement ' .
                'AxalianAchievements\AchievementProvider\AchievementProviderInterface',
                (is_object($plugin) ? get_class($plugin) : gettype($plugin))
            )
        );
    }
677450
private function validate()
    {
        if (!class_exists($this->class)) {
            throw new \RuntimeException(sprintf('Class %s does not exist, is this the correct namespace?', $this->class));
        }
        if (!in_array($this->method, get_class_methods($this->class))) {
            throw new \RuntimeException(sprintf('The method "%s" does not exist in "%s" class.', $this->method, $this->class));
        }
    }
1323234
public static function isBoldgridPlugin( $plugin ) {
		if( empty( $plugin ) ) {
			return false;
		}

		$pluginChecker = new \Boldgrid\Library\Library\Plugin\Checker();

		$plugins = \Boldgrid\Library\Library\Util\Plugin::getFiltered( $pluginChecker->getPluginPattern() );

		return array_key_exists( $plugin, $plugins );
	}