Records time for a plugin that just finished loading.

@param string $plugin Plugin file path.
779534
public function plugin_loaded( string $plugin ): void {

		$time            = microtime( true );
		$this->entries[] = [
			'name'     => $plugin,
			'origin'   => $this->last,
			'duration' => $time - $this->last,
		];
		$this->last      = $time;
	}
441857
public static function registerRedactorPlugin(string $plugin)
    {
        if (isset(self::$_registeredPlugins[$plugin])) {
            return;
        }

        $paths = self::redactorPluginPaths();

        foreach ($paths as $registeredPath) {
            foreach (["{$registeredPath}/{$plugin}", $registeredPath] as $path) {
                if (file_exists("{$path}/{$plugin}.js")) {
                    $view = Craft::$app->getView();
                    $baseUrl = Craft::$app->getAssetManager()->getPublishedUrl($path, true);
                    $view->registerJsFile("{$baseUrl}/{$plugin}.js", [
                        'depends' => RedactorAsset::class
                    ]);
                    // CSS file too?
                    if (file_exists("{$path}/{$plugin}.css")) {
                        $view->registerCssFile("{$baseUrl}/{$plugin}.css");
                    }
                    // Don't do this twice
                    self::$_registeredPlugins[$plugin] = true;
                    return;
                }
            }
        }

        throw new InvalidConfigException('Redactor plugin not found: '.$plugin);
    }
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
        ));
    }
697207
public function addLoadedPlugin($pluginName, Plugin $newPlugin)
    {
        $this->resetTransientCache();

        $this->loadedPlugins[$pluginName] = $newPlugin;
    }
135749
public function isSaved(PluginBundleInterface $plugin)
    {
        if (null !== $this->pluginRepository->findOneByBundleFQCN(get_class($plugin))) {
            return true;
        }

        return false;
    }
484900
protected function activatePlugin(string $plugin): void
    {
        require_once WPMU_PLUGIN_DIR.'/'.$plugin;

        do_action('activate_'.$plugin);

        $plugins = $this->getActivePlugins();
        $plugins[] = $plugin;

        $this->setActivePlugins($plugins);
    }
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))
        ));
    }
731158
public static function getManifestPath($plugin)
    {
        if (self::loaded($plugin)) {
            return FS::clean(self::path($plugin) . DS . self::PLUGIN_MANIFEST);
        }

        return null;
    }
160352
public function validatePlugin($plugin)
    {
        if ($plugin instanceof RouteInterface) {
            // we're okay
            return;
        }

        throw new RuntimeException(sprintf(
            'Plugin of type %s is invalid; must implement %s\RouteInterface',
            (is_object($plugin) ? get_class($plugin) : gettype($plugin)),
            __NAMESPACE__
        ));
    }
1350342
public function isLoaded($plugin)
    {
        $pluginClass = get_class($this->getBundle($plugin));

        foreach ($this->loadedBundles as $bundle => $isEnabled) {
            if ($bundle === $pluginClass && $isEnabled) {
                return true;
            }
        }

        return false;
    }
425837
public function appendPlugin(Plugin ...$plugin): self
    {
        foreach ($plugin as $p) {
            $this->appendPlugins[] = $p;
        }

        return $this;
    }
164928
protected function _modifyBootstrap($plugin)
    {
        $finder = "@\nPlugin::load\((.|.\n|\n\s\s|\n\t|)+'$plugin'(.|.\n|)+\);\n@";

        $bootstrap = new File($this->bootstrap, false);
        $content = $bootstrap->read();

        if (!preg_match("@\n\s*Plugin::loadAll@", $content)) {
            $newContent = preg_replace($finder, '', $content);

            if ($newContent === $content) {
                return false;
            }

            $bootstrap->write($newContent);

            $this->out('');
            $this->out(sprintf('%s modified', $this->bootstrap));

            return true;
        }

        return false;
    }
696538
public function validatePlugin($plugin)
    {
        try {
            $this->validate($plugin);
        } catch (InvalidServiceException $e) {
            throw new RuntimeException($e->getMessage(), $e->getCode(), $e);
        }
    }
1042152
public static function static_function($plugin, $function) {
        global $CFG;

        //check that the plugin exists
        $typedirectory = $CFG->dirroot . '/repository/'. $plugin . '/lib.php';
        if (!file_exists($typedirectory)) {
            //throw new repository_exception('invalidplugin', 'repository');
            return false;
        }

        $args = func_get_args();
        if (count($args) <= 2) {
            $args = array();
        } else {
            array_shift($args);
            array_shift($args);
        }

        require_once($typedirectory);
        return call_user_func_array(array('repository_' . $plugin, $function), $args);
    }
805979
public function validatePlugin($plugin)
    {
        if ($plugin instanceof MvcAuthServiceInterface) {
            // we're okay
            return;
        }

        throw new \Exception(
            sprintf(
                'Plugin of type %s is invalid; must implement MvcAuthServiceInterface',
                is_object($plugin) ? get_class($plugin) : gettype($plugin)
            )
        );
    }
158500
public function isPluginDismissed( $plugin ) {
		$dismissed = false;

		$plugin_prompts = $this->getPluginPrompts( $plugin );

		foreach ( $plugin_prompts as $prompt ) {
			if ( ! empty( $prompt['time_dismissed'] ) ) {
				$dismissed = true;
			}
		}

		return $dismissed;
	}
160826
public function isLocked($plugin)
    {
        $requiredBy = $this->getRequiredBy($plugin);

        foreach ($requiredBy as $required) {
            if ($this->isLoaded($required)) {
                return true;
            }
        }

        return false;
    }