parent
edfab74ff2
commit
41fc15a7e8
12 changed files with 53 additions and 61 deletions
|
@ -4,7 +4,7 @@ set -e
|
|||
[ -n "$PICO_BUILD_ENV" ] || { echo "No Pico build environment specified" >&2; exit 1; }
|
||||
|
||||
# get current Pico milestone
|
||||
VERSION="$(php -r "require_once('$PICO_PROJECT_DIR/lib/Pico.php'); echo picocms\Pico\Pico::VERSION;")"
|
||||
VERSION="$(php -r "require_once('$PICO_PROJECT_DIR/lib/Pico.php'); echo Pico::VERSION;")"
|
||||
MILESTONE="Pico$([[ "$VERSION" =~ ^([0-9]+\.[0-9]+)\. ]] && echo " ${BASH_REMATCH[1]}")"
|
||||
|
||||
echo "Deploying $PROJECT_REPO_BRANCH branch ($MILESTONE)..."
|
||||
|
|
|
@ -24,7 +24,7 @@ if [ -z "$COMPOSER_ROOT_VERSION" ] && [ -n "$PROJECT_REPO_BRANCH" ]; then
|
|||
if [ -z "$PICO_VERSION_PATTERN" ]; then
|
||||
PICO_VERSION_PATTERN="$(php -r "
|
||||
require_once('$PICO_PROJECT_DIR/lib/Pico.php');
|
||||
echo preg_replace('/\.[0-9]+-dev$/', '.x-dev', picocms\Pico\Pico::VERSION);
|
||||
echo preg_replace('/\.[0-9]+-dev$/', '.x-dev', Pico::VERSION);
|
||||
")"
|
||||
fi
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ echo
|
|||
if [ -z "$VERSION" ]; then
|
||||
PICO_VERSION="$(php -r "
|
||||
require_once('$PICO_PROJECT_DIR/lib/Pico.php');
|
||||
echo preg_replace('/-(?:dev|n|nightly)(?:[.-]?[0-9]+)?(?:[.-]dev)?$/', '', picocms\Pico\Pico::VERSION);
|
||||
echo preg_replace('/-(?:dev|n|nightly)(?:[.-]?[0-9]+)?(?:[.-]dev)?$/', '', Pico::VERSION);
|
||||
")"
|
||||
|
||||
VERSION="v$PICO_VERSION-dev+${PROJECT_REPO_BRANCH:-master}"
|
||||
|
|
|
@ -33,7 +33,7 @@ jobs:
|
|||
install:
|
||||
- install.sh --deploy
|
||||
script:
|
||||
- '[ "$PROJECT_REPO_TAG" == "v$(php -r "require_once(\"lib/Pico.php\"); echo picocms\Pico\Pico::VERSION;")" ]'
|
||||
- '[ "$PROJECT_REPO_TAG" == "v$(php -r "require_once(\"lib/Pico.php\"); echo Pico::VERSION;")" ]'
|
||||
- deploy-release.sh
|
||||
before_deploy:
|
||||
- release.sh "$PROJECT_REPO_TAG"
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"picocms\\Pico\\": "lib/"
|
||||
"": "lib/"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
|
|
|
@ -26,7 +26,7 @@ if (is_file(__DIR__ . '/vendor/autoload.php')) {
|
|||
}
|
||||
|
||||
// instance Pico
|
||||
$pico = new \picocms\Pico\Pico(
|
||||
$pico = new Pico(
|
||||
__DIR__, // root dir
|
||||
'config/', // config dir
|
||||
'plugins/', // plugins dir
|
||||
|
|
|
@ -25,7 +25,7 @@ if (!extension_loaded('mbstring')) {
|
|||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
// instance Pico
|
||||
$pico = new \picocms\Pico\Pico(
|
||||
$pico = new Pico(
|
||||
__DIR__, // root dir
|
||||
'config/', // config dir
|
||||
'plugins/', // plugins dir
|
||||
|
|
|
@ -10,27 +10,25 @@
|
|||
* License-Filename: LICENSE
|
||||
*/
|
||||
|
||||
namespace picocms\Pico;
|
||||
|
||||
/**
|
||||
* Abstract class to extend from when implementing a Pico plugin
|
||||
*
|
||||
* Please refer to {@see PluginInterface} for more information about how to
|
||||
* Please refer to {@see PicoPluginInterface} for more information about how to
|
||||
* develop a plugin for Pico.
|
||||
*
|
||||
* @see PluginInterface
|
||||
* @see PicoPluginInterface
|
||||
*
|
||||
* @author Daniel Rudolf
|
||||
* @link http://picocms.org
|
||||
* @license http://opensource.org/licenses/MIT The MIT License
|
||||
* @version 3.0
|
||||
*/
|
||||
abstract class AbstractPlugin implements PluginInterface
|
||||
abstract class AbstractPicoPlugin implements PicoPluginInterface
|
||||
{
|
||||
/**
|
||||
* Current instance of Pico
|
||||
*
|
||||
* @see PluginInterface::getPico()
|
||||
* @see PicoPluginInterface::getPico()
|
||||
* @var Pico
|
||||
*/
|
||||
protected $pico;
|
||||
|
@ -38,8 +36,8 @@ abstract class AbstractPlugin implements PluginInterface
|
|||
/**
|
||||
* Boolean indicating if this plugin is enabled (TRUE) or disabled (FALSE)
|
||||
*
|
||||
* @see PluginInterface::isEnabled()
|
||||
* @see PluginInterface::setEnabled()
|
||||
* @see PicoPluginInterface::isEnabled()
|
||||
* @see PicoPluginInterface::setEnabled()
|
||||
* @var bool|null
|
||||
*/
|
||||
protected $enabled;
|
||||
|
@ -47,7 +45,7 @@ abstract class AbstractPlugin implements PluginInterface
|
|||
/**
|
||||
* Boolean indicating if this plugin was ever enabled/disabled manually
|
||||
*
|
||||
* @see PluginInterface::isStatusChanged()
|
||||
* @see PicoPluginInterface::isStatusChanged()
|
||||
* @var bool
|
||||
*/
|
||||
protected $statusChanged = false;
|
||||
|
@ -55,7 +53,7 @@ abstract class AbstractPlugin implements PluginInterface
|
|||
/**
|
||||
* Boolean indicating whether this plugin matches Pico's API version
|
||||
*
|
||||
* @see AbstractPlugin::checkCompatibility()
|
||||
* @see AbstractPicoPlugin::checkCompatibility()
|
||||
* @var bool|null
|
||||
*/
|
||||
protected $nativePlugin;
|
||||
|
@ -63,8 +61,8 @@ abstract class AbstractPlugin implements PluginInterface
|
|||
/**
|
||||
* List of plugins which this plugin depends on
|
||||
*
|
||||
* @see AbstractPlugin::checkDependencies()
|
||||
* @see PluginInterface::getDependencies()
|
||||
* @see AbstractPicoPlugin::checkDependencies()
|
||||
* @see PicoPluginInterface::getDependencies()
|
||||
* @var string[]
|
||||
*/
|
||||
protected $dependsOn = [];
|
||||
|
@ -72,8 +70,8 @@ abstract class AbstractPlugin implements PluginInterface
|
|||
/**
|
||||
* List of plugin which depend on this plugin
|
||||
*
|
||||
* @see AbstractPlugin::checkDependants()
|
||||
* @see PluginInterface::getDependants()
|
||||
* @see AbstractPicoPlugin::checkDependants()
|
||||
* @see PicoPluginInterface::getDependants()
|
||||
* @var object[]|null
|
||||
*/
|
||||
protected $dependants;
|
||||
|
@ -198,7 +196,7 @@ abstract class AbstractPlugin implements PluginInterface
|
|||
/**
|
||||
* Enables all plugins which this plugin depends on
|
||||
*
|
||||
* @see PluginInterface::getDependencies()
|
||||
* @see PicoPluginInterface::getDependencies()
|
||||
*
|
||||
* @param bool $recursive enable required plugins automatically
|
||||
*
|
||||
|
@ -217,7 +215,7 @@ abstract class AbstractPlugin implements PluginInterface
|
|||
}
|
||||
|
||||
// plugins which don't implement PicoPluginInterface are always enabled
|
||||
if (($plugin instanceof PluginInterface) && !$plugin->isEnabled()) {
|
||||
if (($plugin instanceof PicoPluginInterface) && !$plugin->isEnabled()) {
|
||||
if ($recursive) {
|
||||
if (!$plugin->isStatusChanged()) {
|
||||
$plugin->setEnabled(true, true, true);
|
||||
|
@ -248,7 +246,7 @@ abstract class AbstractPlugin implements PluginInterface
|
|||
/**
|
||||
* Disables all plugins which depend on this plugin
|
||||
*
|
||||
* @see PluginInterface::getDependants()
|
||||
* @see PicoPluginInterface::getDependants()
|
||||
*
|
||||
* @param bool $recursive disabled dependant plugins automatically
|
||||
*
|
||||
|
@ -291,7 +289,7 @@ abstract class AbstractPlugin implements PluginInterface
|
|||
$this->dependants = [];
|
||||
foreach ($this->getPico()->getPlugins() as $pluginName => $plugin) {
|
||||
// only plugins which implement PicoPluginInterface support dependencies
|
||||
if ($plugin instanceof PluginInterface) {
|
||||
if ($plugin instanceof PicoPluginInterface) {
|
||||
$dependencies = $plugin->getDependencies();
|
||||
if (in_array(get_called_class(), $dependencies)) {
|
||||
$this->dependants[$pluginName] = $plugin;
|
40
lib/Pico.php
40
lib/Pico.php
|
@ -16,8 +16,6 @@
|
|||
* License-Filename: LICENSE
|
||||
*/
|
||||
|
||||
namespace picocms\Pico;
|
||||
|
||||
use Symfony\Component\Yaml\Parser as YamlParser;
|
||||
use Twig\Environment as TwigEnvironment;
|
||||
use Twig\Extension\DebugExtension as TwigDebugExtension;
|
||||
|
@ -156,7 +154,7 @@ class Pico
|
|||
/**
|
||||
* List of loaded plugins using the current API version
|
||||
*
|
||||
* @var PluginInterface[]
|
||||
* @var PicoPluginInterface[]
|
||||
*/
|
||||
protected $nativePlugins = [];
|
||||
|
||||
|
@ -607,7 +605,7 @@ class Pico
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!($plugin instanceof PluginInterface)) {
|
||||
if (!($plugin instanceof PicoPluginInterface)) {
|
||||
throw new \RuntimeException(
|
||||
"Unable to load plugin '" . $className . "' via 'vendor/pico-plugin.php': "
|
||||
. "Plugins installed by composer must implement 'PicoPluginInterface'"
|
||||
|
@ -698,7 +696,7 @@ class Pico
|
|||
|
||||
$this->plugins[$className] = $plugin;
|
||||
|
||||
if ($plugin instanceof PluginInterface) {
|
||||
if ($plugin instanceof PicoPluginInterface) {
|
||||
if (defined($className . '::API_VERSION') && ($className::API_VERSION >= static::API_VERSION)) {
|
||||
$this->nativePlugins[$className] = $plugin;
|
||||
}
|
||||
|
@ -714,11 +712,11 @@ class Pico
|
|||
/**
|
||||
* Manually loads a plugin
|
||||
*
|
||||
* Manually loaded plugins MUST implement {@see PluginInterface}. 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
|
||||
* 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.
|
||||
*
|
||||
|
@ -736,10 +734,10 @@ class Pico
|
|||
* @see Pico::getPlugin()
|
||||
* @see Pico::getPlugins()
|
||||
*
|
||||
* @param PluginInterface|string $plugin either the class name of a plugin
|
||||
* to instantiate or a plugin instance
|
||||
* @param PicoPluginInterface|string $plugin either the class name of a
|
||||
* 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
|
||||
*/
|
||||
|
@ -756,7 +754,7 @@ class Pico
|
|||
|
||||
$className = get_class($plugin);
|
||||
|
||||
if (!($plugin instanceof PluginInterface)) {
|
||||
if (!($plugin instanceof PicoPluginInterface)) {
|
||||
throw new \RuntimeException(
|
||||
"Unable to load plugin '" . $className . "': "
|
||||
. "Manually loaded plugins must implement 'PicoPluginInterface'"
|
||||
|
@ -826,7 +824,7 @@ class Pico
|
|||
$visitedPlugins[$pluginName] = true;
|
||||
|
||||
$dependencies = [];
|
||||
if ($plugin instanceof PluginInterface) {
|
||||
if ($plugin instanceof PicoPluginInterface) {
|
||||
$dependencies = $plugin->getDependencies();
|
||||
}
|
||||
if (!isset($nativePlugins[$pluginName])) {
|
||||
|
@ -863,8 +861,8 @@ class Pico
|
|||
/**
|
||||
* Returns the instance of a named plugin
|
||||
*
|
||||
* Plugins SHOULD implement {@see PluginInterface}, but you MUST NOT rely
|
||||
* on it. For more information see {@see PluginInterface}.
|
||||
* Plugins SHOULD implement {@see PicoPluginInterface}, but you MUST NOT
|
||||
* rely on it. For more information see {@see PicoPluginInterface}.
|
||||
*
|
||||
* @see Pico::loadPlugins()
|
||||
* @see Pico::getPlugins()
|
||||
|
@ -2106,7 +2104,7 @@ class Pico
|
|||
* This method triggers the `onTwigRegistered` event when the Twig template
|
||||
* engine wasn't initiated yet. When initiating Twig, this method also
|
||||
* registers Pico's core Twig filter `content` as well as Pico's
|
||||
* {@see TwigExtension} Twig extension.
|
||||
* {@see PicoTwigExtension} Twig extension.
|
||||
*
|
||||
* @see Pico::getTwig()
|
||||
* @see http://twig.sensiolabs.org/ Twig website
|
||||
|
@ -2121,7 +2119,7 @@ class Pico
|
|||
|
||||
$twigLoader = new TwigFilesystemLoader($this->getThemesDir() . $this->getTheme());
|
||||
$this->twig = new TwigEnvironment($twigLoader, $twigConfig);
|
||||
$this->twig->addExtension(new TwigExtension($this));
|
||||
$this->twig->addExtension(new PicoTwigExtension($this));
|
||||
|
||||
if (!empty($twigConfig['debug'])) {
|
||||
$this->twig->addExtension(new TwigDebugExtension());
|
||||
|
@ -2778,8 +2776,8 @@ class Pico
|
|||
*
|
||||
* You MUST NOT trigger events of Pico's core with a plugin!
|
||||
*
|
||||
* @see PluginInterface
|
||||
* @see AbstractPlugin
|
||||
* @see PicoPluginInterface
|
||||
* @see AbstractPicoPlugin
|
||||
* @see DummyPlugin
|
||||
*
|
||||
* @param string $eventName name of the event to trigger
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
* License-Filename: LICENSE
|
||||
*/
|
||||
|
||||
namespace picocms\Pico;
|
||||
|
||||
/**
|
||||
* Common interface for Pico plugins
|
||||
*
|
||||
|
@ -30,7 +28,7 @@ namespace picocms\Pico;
|
|||
* @license http://opensource.org/licenses/MIT The MIT License
|
||||
* @version 3.0
|
||||
*/
|
||||
interface PluginInterface
|
||||
interface PicoPluginInterface
|
||||
{
|
||||
/**
|
||||
* Handles a event that was triggered by Pico
|
||||
|
@ -43,8 +41,8 @@ interface PluginInterface
|
|||
/**
|
||||
* Enables or disables this plugin
|
||||
*
|
||||
* @see PluginInterface::isEnabled()
|
||||
* @see PluginInterface::isStatusChanged()
|
||||
* @see PicoPluginInterface::isEnabled()
|
||||
* @see PicoPluginInterface::isStatusChanged()
|
||||
*
|
||||
* @param bool $enabled enable (TRUE) or disable (FALSE) this plugin
|
||||
* @param bool $recursive when TRUE, enable or disable recursively.
|
||||
|
@ -67,7 +65,7 @@ interface PluginInterface
|
|||
* wasn't triggered on all plugins yet. This method might even return NULL
|
||||
* then. The plugin's status might change later.
|
||||
*
|
||||
* @see PluginInterface::setEnabled()
|
||||
* @see PicoPluginInterface::setEnabled()
|
||||
*
|
||||
* @return bool|null plugin is enabled (TRUE) or disabled (FALSE)
|
||||
*/
|
||||
|
@ -76,7 +74,7 @@ interface PluginInterface
|
|||
/**
|
||||
* Returns TRUE if the plugin was ever enabled/disabled manually
|
||||
*
|
||||
* @see PluginInterface::setEnabled()
|
||||
* @see PicoPluginInterface::setEnabled()
|
||||
*
|
||||
* @return bool plugin is in its default state (TRUE), FALSE otherwise
|
||||
*/
|
|
@ -10,8 +10,6 @@
|
|||
* License-Filename: LICENSE
|
||||
*/
|
||||
|
||||
namespace picocms\Pico;
|
||||
|
||||
use Twig\Error\RuntimeError as TwigRuntimeError;
|
||||
use Twig\Extension\AbstractExtension as AbstractTwigExtension;
|
||||
use Twig\Extension\ExtensionInterface as TwigExtensionInterface;
|
||||
|
@ -26,12 +24,12 @@ use Twig\TwigFunction;
|
|||
* @license http://opensource.org/licenses/MIT The MIT License
|
||||
* @version 3.0
|
||||
*/
|
||||
class TwigExtension extends AbstractTwigExtension
|
||||
class PicoTwigExtension extends AbstractTwigExtension
|
||||
{
|
||||
/**
|
||||
* Current instance of Pico
|
||||
*
|
||||
* @see TwigExtension::getPico()
|
||||
* @see PicoTwigExtension::getPico()
|
||||
* @var Pico
|
||||
*/
|
||||
private $pico;
|
|
@ -10,7 +10,7 @@
|
|||
* License-Filename: LICENSE
|
||||
*/
|
||||
|
||||
use picocms\Pico\AbstractPlugin;
|
||||
use picocms\Pico\AbstractPicoPlugin;
|
||||
use picocms\Pico\Pico;
|
||||
use Twig\Environment as TwigEnvironment;
|
||||
|
||||
|
@ -25,7 +25,7 @@ use Twig\Environment as TwigEnvironment;
|
|||
* @license http://opensource.org/licenses/MIT The MIT License
|
||||
* @version 3.0
|
||||
*/
|
||||
class DummyPlugin extends AbstractPlugin
|
||||
class DummyPlugin extends AbstractPicoPlugin
|
||||
{
|
||||
/**
|
||||
* API version used by this plugin
|
||||
|
@ -56,7 +56,7 @@ class DummyPlugin extends AbstractPlugin
|
|||
* No matter what, the user can always explicitly enable or disable this
|
||||
* plugin in Pico's config.
|
||||
*
|
||||
* @see AbstractPlugin::$enabled
|
||||
* @see AbstractPicoPlugin::$enabled
|
||||
* @var bool|null
|
||||
*/
|
||||
protected $enabled = false;
|
||||
|
@ -67,7 +67,7 @@ class DummyPlugin extends AbstractPlugin
|
|||
* If your plugin doesn't depend on any other plugin, remove this class
|
||||
* property.
|
||||
*
|
||||
* @see AbstractPlugin::$dependsOn
|
||||
* @see AbstractPicoPlugin::$dependsOn
|
||||
* @var string[]
|
||||
*/
|
||||
protected $dependsOn = array();
|
||||
|
|
Loading…
Reference in a new issue