|
|
@ -16,8 +16,6 @@ |
|
|
|
* License-Filename: LICENSE |
|
|
|
* License-Filename: LICENSE |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
namespace picocms\Pico; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use Symfony\Component\Yaml\Parser as YamlParser; |
|
|
|
use Symfony\Component\Yaml\Parser as YamlParser; |
|
|
|
use Twig\Environment as TwigEnvironment; |
|
|
|
use Twig\Environment as TwigEnvironment; |
|
|
|
use Twig\Extension\DebugExtension as TwigDebugExtension; |
|
|
|
use Twig\Extension\DebugExtension as TwigDebugExtension; |
|
|
@ -156,7 +154,7 @@ class Pico |
|
|
|
/** |
|
|
|
/** |
|
|
|
* List of loaded plugins using the current API version |
|
|
|
* List of loaded plugins using the current API version |
|
|
|
* |
|
|
|
* |
|
|
|
* @var PluginInterface[] |
|
|
|
* @var PicoPluginInterface[] |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected $nativePlugins = []; |
|
|
|
protected $nativePlugins = []; |
|
|
|
|
|
|
|
|
|
|
@ -607,7 +605,7 @@ class Pico |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!($plugin instanceof PluginInterface)) { |
|
|
|
if (!($plugin instanceof PicoPluginInterface)) { |
|
|
|
throw new \RuntimeException( |
|
|
|
throw new \RuntimeException( |
|
|
|
"Unable to load plugin '" . $className . "' via 'vendor/pico-plugin.php': " |
|
|
|
"Unable to load plugin '" . $className . "' via 'vendor/pico-plugin.php': " |
|
|
|
. "Plugins installed by composer must implement 'PicoPluginInterface'" |
|
|
|
. "Plugins installed by composer must implement 'PicoPluginInterface'" |
|
|
@ -698,7 +696,7 @@ class Pico |
|
|
|
|
|
|
|
|
|
|
|
$this->plugins[$className] = $plugin; |
|
|
|
$this->plugins[$className] = $plugin; |
|
|
|
|
|
|
|
|
|
|
|
if ($plugin instanceof PluginInterface) { |
|
|
|
if ($plugin instanceof PicoPluginInterface) { |
|
|
|
if (defined($className . '::API_VERSION') && ($className::API_VERSION >= static::API_VERSION)) { |
|
|
|
if (defined($className . '::API_VERSION') && ($className::API_VERSION >= static::API_VERSION)) { |
|
|
|
$this->nativePlugins[$className] = $plugin; |
|
|
|
$this->nativePlugins[$className] = $plugin; |
|
|
|
} |
|
|
|
} |
|
|
@ -714,11 +712,11 @@ class Pico |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Manually loads a plugin |
|
|
|
* Manually loads a plugin |
|
|
|
* |
|
|
|
* |
|
|
|
* Manually loaded plugins MUST implement {@see PluginInterface}. They are |
|
|
|
* Manually loaded plugins MUST implement {@see PicoPluginInterface}. They |
|
|
|
* simply appended to the plugins array without any additional checks, so |
|
|
|
* are simply appended to the plugins array without any additional checks, |
|
|
|
* you might get unexpected results, depending on *when* you're loading a |
|
|
|
* so you might get unexpected results, depending on *when* you're loading |
|
|
|
* plugin. You SHOULD NOT load plugins after a event has been triggered by |
|
|
|
* a plugin. You SHOULD NOT load plugins after a event has been triggered |
|
|
|
* Pico. In-depth knowledge of Pico's inner workings is strongly advised |
|
|
|
* by Pico. In-depth knowledge of Pico's inner workings is strongly advised |
|
|
|
* otherwise, and you MUST NOT rely on {@see PicoDeprecated} to maintain |
|
|
|
* otherwise, and you MUST NOT rely on {@see PicoDeprecated} to maintain |
|
|
|
* backward compatibility in such cases. |
|
|
|
* backward compatibility in such cases. |
|
|
|
* |
|
|
|
* |
|
|
@ -736,10 +734,10 @@ class Pico |
|
|
|
* @see Pico::getPlugin() |
|
|
|
* @see Pico::getPlugin() |
|
|
|
* @see Pico::getPlugins() |
|
|
|
* @see Pico::getPlugins() |
|
|
|
* |
|
|
|
* |
|
|
|
* @param PluginInterface|string $plugin either the class name of a plugin |
|
|
|
* @param PicoPluginInterface|string $plugin either the class name of a |
|
|
|
* to instantiate or a plugin instance |
|
|
|
* plugin to instantiate or a plugin instance |
|
|
|
* |
|
|
|
* |
|
|
|
* @return PluginInterface instance of the loaded plugin |
|
|
|
* @return PicoPluginInterface instance of the loaded plugin |
|
|
|
* |
|
|
|
* |
|
|
|
* @throws \RuntimeException thrown when the plugin couldn't be loaded |
|
|
|
* @throws \RuntimeException thrown when the plugin couldn't be loaded |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -756,7 +754,7 @@ class Pico |
|
|
|
|
|
|
|
|
|
|
|
$className = get_class($plugin); |
|
|
|
$className = get_class($plugin); |
|
|
|
|
|
|
|
|
|
|
|
if (!($plugin instanceof PluginInterface)) { |
|
|
|
if (!($plugin instanceof PicoPluginInterface)) { |
|
|
|
throw new \RuntimeException( |
|
|
|
throw new \RuntimeException( |
|
|
|
"Unable to load plugin '" . $className . "': " |
|
|
|
"Unable to load plugin '" . $className . "': " |
|
|
|
. "Manually loaded plugins must implement 'PicoPluginInterface'" |
|
|
|
. "Manually loaded plugins must implement 'PicoPluginInterface'" |
|
|
@ -826,7 +824,7 @@ class Pico |
|
|
|
$visitedPlugins[$pluginName] = true; |
|
|
|
$visitedPlugins[$pluginName] = true; |
|
|
|
|
|
|
|
|
|
|
|
$dependencies = []; |
|
|
|
$dependencies = []; |
|
|
|
if ($plugin instanceof PluginInterface) { |
|
|
|
if ($plugin instanceof PicoPluginInterface) { |
|
|
|
$dependencies = $plugin->getDependencies(); |
|
|
|
$dependencies = $plugin->getDependencies(); |
|
|
|
} |
|
|
|
} |
|
|
|
if (!isset($nativePlugins[$pluginName])) { |
|
|
|
if (!isset($nativePlugins[$pluginName])) { |
|
|
@ -863,8 +861,8 @@ class Pico |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns the instance of a named plugin |
|
|
|
* Returns the instance of a named plugin |
|
|
|
* |
|
|
|
* |
|
|
|
* Plugins SHOULD implement {@see PluginInterface}, but you MUST NOT rely |
|
|
|
* Plugins SHOULD implement {@see PicoPluginInterface}, but you MUST NOT |
|
|
|
* on it. For more information see {@see PluginInterface}. |
|
|
|
* rely on it. For more information see {@see PicoPluginInterface}. |
|
|
|
* |
|
|
|
* |
|
|
|
* @see Pico::loadPlugins() |
|
|
|
* @see Pico::loadPlugins() |
|
|
|
* @see Pico::getPlugins() |
|
|
|
* @see Pico::getPlugins() |
|
|
@ -2106,7 +2104,7 @@ class Pico |
|
|
|
* This method triggers the `onTwigRegistered` event when the Twig template |
|
|
|
* This method triggers the `onTwigRegistered` event when the Twig template |
|
|
|
* engine wasn't initiated yet. When initiating Twig, this method also |
|
|
|
* engine wasn't initiated yet. When initiating Twig, this method also |
|
|
|
* registers Pico's core Twig filter `content` as well as Pico's |
|
|
|
* registers Pico's core Twig filter `content` as well as Pico's |
|
|
|
* {@see TwigExtension} Twig extension. |
|
|
|
* {@see PicoTwigExtension} Twig extension. |
|
|
|
* |
|
|
|
* |
|
|
|
* @see Pico::getTwig() |
|
|
|
* @see Pico::getTwig() |
|
|
|
* @see http://twig.sensiolabs.org/ Twig website |
|
|
|
* @see http://twig.sensiolabs.org/ Twig website |
|
|
@ -2121,7 +2119,7 @@ class Pico |
|
|
|
|
|
|
|
|
|
|
|
$twigLoader = new TwigFilesystemLoader($this->getThemesDir() . $this->getTheme()); |
|
|
|
$twigLoader = new TwigFilesystemLoader($this->getThemesDir() . $this->getTheme()); |
|
|
|
$this->twig = new TwigEnvironment($twigLoader, $twigConfig); |
|
|
|
$this->twig = new TwigEnvironment($twigLoader, $twigConfig); |
|
|
|
$this->twig->addExtension(new TwigExtension($this)); |
|
|
|
$this->twig->addExtension(new PicoTwigExtension($this)); |
|
|
|
|
|
|
|
|
|
|
|
if (!empty($twigConfig['debug'])) { |
|
|
|
if (!empty($twigConfig['debug'])) { |
|
|
|
$this->twig->addExtension(new TwigDebugExtension()); |
|
|
|
$this->twig->addExtension(new TwigDebugExtension()); |
|
|
@ -2778,8 +2776,8 @@ class Pico |
|
|
|
* |
|
|
|
* |
|
|
|
* You MUST NOT trigger events of Pico's core with a plugin! |
|
|
|
* You MUST NOT trigger events of Pico's core with a plugin! |
|
|
|
* |
|
|
|
* |
|
|
|
* @see PluginInterface |
|
|
|
* @see PicoPluginInterface |
|
|
|
* @see AbstractPlugin |
|
|
|
* @see AbstractPicoPlugin |
|
|
|
* @see DummyPlugin |
|
|
|
* @see DummyPlugin |
|
|
|
* |
|
|
|
* |
|
|
|
* @param string $eventName name of the event to trigger |
|
|
|
* @param string $eventName name of the event to trigger |
|
|
|