lib/Pico.php
public function loadPlugin($plugin)
    {
        if (!is_object($plugin)) {
            $className = (string) $plugin;
            if (class_exists($className)) {
                $plugin = new $className($this);
            } else {
                throw new RuntimeException("Unable to load plugin '" . $className . "':  Class not found");
            }
        }

        $className = get_class($plugin);

        if (!($plugin instanceof PicoPluginInterface)) {
            throw new RuntimeException(
                "Unable to load plugin '" . $className . "': "
                . "Manually loaded plugins must implement 'PicoPluginInterface'"
            );
        }

        $this->plugins[$className] = $plugin;

        if (defined($className . '::API_VERSION') && ($className::API_VERSION >= static::API_VERSION)) {
            $this->nativePlugins[$className] = $plugin;
        }

        // trigger onPluginManuallyLoaded event
        // the event is also triggered on the newly loaded plugin, allowing you to distinguish manual and auto loading
        $this->triggerEvent('onPluginManuallyLoaded', array($plugin));

        return $plugin;
    }
public function loadPlugin($plugin)
    {
        if (!is_object($plugin)) {
            $className = (string) $plugin;
            if (class_exists($className)) {
                $plugin = new $className($this);
            } else {
                throw new RuntimeException("Unable to load plugin '" . $className . "':  Class not found");
            }
        }

        $className = get_class($plugin);

        if (!($plugin instanceof PicoPluginInterface)) {
            throw new RuntimeException(
                "Unable to load plugin '" . $className . "': "
                . "Manually loaded plugins must implement 'PicoPluginInterface'"
            );
        }

        $this->plugins[$className] = $plugin;

        if (defined($className . '::API_VERSION') && ($className::API_VERSION >= static::API_VERSION)) {
            $this->nativePlugins[$className] = $plugin;
        }

        // trigger onPluginManuallyLoaded event
        // the event is also triggered on the newly loaded plugin, allowing you to distinguish manual and auto loading
        $this->triggerEvent('onPluginManuallyLoaded', array($plugin));

        return $plugin;
    }
public function loadPlugin ( $ plugin ) { if ( ! is_object ( $ plugin ) ) { $ className = ( string ) $ plugin ; if ( class_exists ( $ className ) ) { $ plugin = new $ className ( $ this ) ; } else { throw new RuntimeException ( "Unable to load plugin '" . $ className . "':  Class not found" ) ; } } $ className = get_class ( $ plugin ) ; if ( ! ( $ plugin instanceof PicoPluginInterface ) ) { throw new RuntimeException ( "Unable to load plugin '" . $ className . "': " . "Manually loaded plugins must implement 'PicoPluginInterface'" ) ; } $ this -> plugins [ $ className ] = $ plugin ; if ( defined ( $ className . '::API_VERSION' ) && ( $ className :: API_VERSION >= static :: API_VERSION ) ) { $ this -> nativePlugins [ $ className ] = $ plugin ; } // trigger onPluginManuallyLoaded event // the event is also triggered on the newly loaded plugin, allowing you to distinguish manual and auto loading $ this -> triggerEvent ( 'onPluginManuallyLoaded' , array ( $ plugin ) ) ; return $ plugin ; }
Manually loads a plugin

Manually loaded plugins MUST implement {@see PicoPluginInterface}. They
are simply appended to the plugins array without any additional checks,
so you might get unexpected results, depending on *when* you're loading
a plugin. You SHOULD NOT load plugins after a event has been triggered
by Pico. In-depth knowledge of Pico's inner workings is strongly advised
otherwise, and you MUST NOT rely on {@see PicoDeprecated} to maintain
backward compatibility in such cases.

If you e.g. load a plugin after the `onPluginsLoaded` event, Pico
doesn't guarantee the plugin's order ({@see Pico::sortPlugins()}).
Already triggered events won't get triggered on the manually loaded
plugin. Thus you SHOULD load plugins either before {@see Pico::run()}
is called, or via the constructor of another plugin (i.e. the plugin's
`__construct()` method; plugins are instanced in
{@see Pico::loadPlugins()}).

This method triggers the `onPluginManuallyLoaded` event.

@see Pico::loadPlugins()
@see Pico::getPlugin()
@see Pico::getPlugins()

@param PicoPluginInterface|string $plugin either the class name of a
plugin to instantiate or a plugin instance

@return PicoPluginInterface instance of the loaded plugin

@throws RuntimeException thrown when a plugin couldn't be loaded
Manually loads a plugin