Find the requirements for a given plugin type.

@param Plugin $plugin
@param int    $moodleVersion

@return AbstractRequirements
512276
public function resolveRequirements(Plugin $plugin, $moodleVersion)
    {
        $map = [
            'auth'       => new AuthRequirements($plugin, $moodleVersion),
            'block'      => new BlockRequirements($plugin, $moodleVersion),
            'filter'     => new FilterRequirements($plugin, $moodleVersion),
            'format'     => new FormatRequirements($plugin, $moodleVersion),
            'mod'        => new ModuleRequirements($plugin, $moodleVersion),
            'qtype'      => new QuestionRequirements($plugin, $moodleVersion),
            'repository' => new RepositoryRequirements($plugin, $moodleVersion),
            'theme'      => new ThemeRequirements($plugin, $moodleVersion),
        ];

        if (array_key_exists($plugin->type, $map)) {
            return $map[$plugin->type];
        }

        return new GenericRequirements($plugin, $moodleVersion);
    }
600194
private function validateComposerPackages(
        array $pluginRequirements,
        RequirementExceptionStack $exceptionStack
    ): array {
        $shopwareProjectComposer = $this->getComposer($this->projectDir);
        $pluginRequirements = $this->checkComposerDependencies(
            $pluginRequirements,
            $exceptionStack,
            $shopwareProjectComposer
        );

        return $pluginRequirements;
    }
268995
static function plugins()
    {
        if (! self::isEnabledPlugins() )
            throw new \Exception('Using Plugins depends on Poirot/Ioc; that not exists currently.');


        if (! self::$pluginManager )
            self::$pluginManager = new PluginsHttpHeader;

        return self::$pluginManager;
    }
7842
private boolean checkPlugin(final String currentPlugin) {
        final Features pluginFeatures = pluginTable.get(currentPlugin);
        final Iterator<PluginRequirement> iter = pluginFeatures.getRequireListIter();
        // check whether dependcy is satisfied
        while (iter.hasNext()) {
            boolean anyPluginFound = false;
            final PluginRequirement requirement = iter.next();
            final Iterator<String> requiredPluginIter = requirement.getPlugins();
            while (requiredPluginIter.hasNext()) {
                // Iterate over all alternatives in plugin requirement.
                final String requiredPlugin = requiredPluginIter.next();
                if (pluginTable.containsKey(requiredPlugin)) {
                    if (!loadedPlugin.contains(requiredPlugin)) {
                        // required plug-in is not loaded
                        loadPlugin(requiredPlugin);
                    }
                    // As soon as any plugin is found, it's OK.
                    anyPluginFound = true;
                }
            }
            if (!anyPluginFound && requirement.getRequired()) {
                // not contain any plugin required by current plugin
                final String msg = MessageUtils.getMessage("DOTJ020W", requirement.toString(), currentPlugin).toString();
                throw new RuntimeException(msg);
            }
        }
        return true;
    }
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))
        ));
    }
398594
public function validatePlugin($plugin)
    {
        if (!$plugin instanceof ModelInterface) {
            throw new Exception\InvalidPluginException(sprintf(
                'Model of type %s is invalid; must implement "%s"',
                (is_object($plugin) ? get_class($plugin) : gettype($plugin)),
                ModelInterface::class
            ));
        }
    }
371260
protected function checkSimple($plugin)
    {
        return ForumEnv::get('FORUM_ROOT') . 'plugins' . DIRECTORY_SEPARATOR . $plugin .
            DIRECTORY_SEPARATOR . $this->getNamespace($plugin) . '.php';
    }
522710
public function installPluginIntoMoodle(MoodlePlugin $plugin)
    {
        $this->getOutput()->info(sprintf('Installing %s', $plugin->getComponent()));

        $directory = $this->moodle->getComponentInstallDirectory($plugin->getComponent());

        if (is_dir($directory)) {
            throw new \RuntimeException('Plugin is already installed in standard Moodle');
        }

        $this->getOutput()->info(sprintf('Copying plugin from %s to %s', $plugin->directory, $directory));

        // Install the plugin.
        $filesystem = new Filesystem();
        $filesystem->mirror($plugin->directory, $directory);

        return $directory;
    }
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
        ));
    }
849899
public static function getDimensions(Plugin $plugin)
    {
        $dimensions = $plugin->findMultipleComponents('Columns', '\\Piwik\\Plugin\\Dimension\\VisitDimension');
        $instances  = array();

        foreach ($dimensions as $dimension) {
            $instances[] = new $dimension();
        }

        return $instances;
    }
300489
public function addPlugin(Plugin $plugin): Builder
    {
        $this->plugins[]          = $plugin;
        $this->httpClientModified = true;

        return $this;
    }
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;
    }
1105589
private function loadPlugins($pluginsDirectory) {
            $pluginsDirectory = MISC::findFile($pluginsDirectory);

            if(file_exists($pluginsDirectory)) {
                $tmp_plugins = array();

                foreach (glob($pluginsDirectory . '/*/*.json') as $file) {
                    $config = json_decode(file_get_contents($file), true);

                    $tmp_plugins[] = array(
                        'name'      => $config['name'],
                        'priority'  => $config['priority'],
                        'directory' => dirname($file),
                        'mainClass' => $config['mainClass'],
                        'classes'   => $config['classes']
                    );
                }

                MISC::array_sort_key($tmp_plugins, 'priority');

                foreach($tmp_plugins as $tmp_plugin) {
                    $plugin = new Plugin($tmp_plugin['name']);
                    $plugin->setMainClass($tmp_plugin['mainClass'])
                        ->setDirectory($tmp_plugin['directory'])
                        ->setPriority($tmp_plugin['priority'])
                        ->setClasses($tmp_plugin['classes']);

                    $this->plugins[] = $plugin;
                    new Logger('Plugin ['. $plugin->getName() .'] successfully loaded.', Logger::INFO, __FILE__, __LINE__);
                }

                new Logger('Plugins successfully loaded.', Logger::INFO, __FILE__, __LINE__);
                return true;
            } else {
                new Logger('Plugins directory wasn\'t found. (' . $pluginsDirectory . ')', Logger::WARNING, __FILE__, __LINE__);
                return false;
            }
        }
578613
private static function find_plugin( $plugin_base_name ) {
		/** @var \Technote $instance */
		foreach ( self::$_instances as $plugin_name => $instance ) {
			if ( $instance->is_theme ) {
				continue;
			}
			$instance->plugins_loaded();
			if ( $instance->define->plugin_base_name === $plugin_base_name ) {
				return $instance;
			}
		}

		return null;
	}
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))
            )
        );
    }
1101754
public static function loadPluginIfAvailable($plugin)
    {
        if (!self::isPluginLoaded($plugin) && self::isPluginAvailable($plugin)) {
            self::loadPlugin($plugin);
        }
    }
1160359
public function validatePlugin($plugin)
    {
        if ($this->isValidModuleOptions($plugin)) {
            return;
        }

        throw new Exception\RuntimeException(sprintf(
            'Plugin of type %s is invalid; must implement %s',
            (is_object($plugin) ? get_class($plugin) : gettype($plugin)),
            ModuleOptionsInterface::class
        ));
    }