Remove picocms\Pico\ namespace

This reverts commit 812ae5c21548905e308f002bc6d97a042ea09aad
This commit is contained in:
Daniel Rudolf 2022-02-06 23:14:08 +01:00
parent edfab74ff2
commit 41fc15a7e8
No known key found for this signature in database
GPG Key ID: A061F02CD8DE4538
12 changed files with 53 additions and 61 deletions

View File

@ -4,7 +4,7 @@ set -e
[ -n "$PICO_BUILD_ENV" ] || { echo "No Pico build environment specified" >&2; exit 1; } [ -n "$PICO_BUILD_ENV" ] || { echo "No Pico build environment specified" >&2; exit 1; }
# get current Pico milestone # 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]}")" MILESTONE="Pico$([[ "$VERSION" =~ ^([0-9]+\.[0-9]+)\. ]] && echo " ${BASH_REMATCH[1]}")"
echo "Deploying $PROJECT_REPO_BRANCH branch ($MILESTONE)..." echo "Deploying $PROJECT_REPO_BRANCH branch ($MILESTONE)..."

View File

@ -24,7 +24,7 @@ if [ -z "$COMPOSER_ROOT_VERSION" ] && [ -n "$PROJECT_REPO_BRANCH" ]; then
if [ -z "$PICO_VERSION_PATTERN" ]; then if [ -z "$PICO_VERSION_PATTERN" ]; then
PICO_VERSION_PATTERN="$(php -r " PICO_VERSION_PATTERN="$(php -r "
require_once('$PICO_PROJECT_DIR/lib/Pico.php'); 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 fi

View File

@ -16,7 +16,7 @@ echo
if [ -z "$VERSION" ]; then if [ -z "$VERSION" ]; then
PICO_VERSION="$(php -r " PICO_VERSION="$(php -r "
require_once('$PICO_PROJECT_DIR/lib/Pico.php'); 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}" VERSION="v$PICO_VERSION-dev+${PROJECT_REPO_BRANCH:-master}"

View File

@ -33,7 +33,7 @@ jobs:
install: install:
- install.sh --deploy - install.sh --deploy
script: 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 - deploy-release.sh
before_deploy: before_deploy:
- release.sh "$PROJECT_REPO_TAG" - release.sh "$PROJECT_REPO_TAG"

View File

@ -44,7 +44,7 @@
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"picocms\\Pico\\": "lib/" "": "lib/"
} }
}, },
"extra": { "extra": {

View File

@ -26,7 +26,7 @@ if (is_file(__DIR__ . '/vendor/autoload.php')) {
} }
// instance Pico // instance Pico
$pico = new \picocms\Pico\Pico( $pico = new Pico(
__DIR__, // root dir __DIR__, // root dir
'config/', // config dir 'config/', // config dir
'plugins/', // plugins dir 'plugins/', // plugins dir

View File

@ -25,7 +25,7 @@ if (!extension_loaded('mbstring')) {
require_once(__DIR__ . '/vendor/autoload.php'); require_once(__DIR__ . '/vendor/autoload.php');
// instance Pico // instance Pico
$pico = new \picocms\Pico\Pico( $pico = new Pico(
__DIR__, // root dir __DIR__, // root dir
'config/', // config dir 'config/', // config dir
'plugins/', // plugins dir 'plugins/', // plugins dir

View File

@ -10,27 +10,25 @@
* License-Filename: LICENSE * License-Filename: LICENSE
*/ */
namespace picocms\Pico;
/** /**
* Abstract class to extend from when implementing a Pico plugin * 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. * develop a plugin for Pico.
* *
* @see PluginInterface * @see PicoPluginInterface
* *
* @author Daniel Rudolf * @author Daniel Rudolf
* @link http://picocms.org * @link http://picocms.org
* @license http://opensource.org/licenses/MIT The MIT License * @license http://opensource.org/licenses/MIT The MIT License
* @version 3.0 * @version 3.0
*/ */
abstract class AbstractPlugin implements PluginInterface abstract class AbstractPicoPlugin implements PicoPluginInterface
{ {
/** /**
* Current instance of Pico * Current instance of Pico
* *
* @see PluginInterface::getPico() * @see PicoPluginInterface::getPico()
* @var Pico * @var Pico
*/ */
protected $pico; protected $pico;
@ -38,8 +36,8 @@ abstract class AbstractPlugin implements PluginInterface
/** /**
* Boolean indicating if this plugin is enabled (TRUE) or disabled (FALSE) * Boolean indicating if this plugin is enabled (TRUE) or disabled (FALSE)
* *
* @see PluginInterface::isEnabled() * @see PicoPluginInterface::isEnabled()
* @see PluginInterface::setEnabled() * @see PicoPluginInterface::setEnabled()
* @var bool|null * @var bool|null
*/ */
protected $enabled; protected $enabled;
@ -47,7 +45,7 @@ abstract class AbstractPlugin implements PluginInterface
/** /**
* Boolean indicating if this plugin was ever enabled/disabled manually * Boolean indicating if this plugin was ever enabled/disabled manually
* *
* @see PluginInterface::isStatusChanged() * @see PicoPluginInterface::isStatusChanged()
* @var bool * @var bool
*/ */
protected $statusChanged = false; protected $statusChanged = false;
@ -55,7 +53,7 @@ abstract class AbstractPlugin implements PluginInterface
/** /**
* Boolean indicating whether this plugin matches Pico's API version * Boolean indicating whether this plugin matches Pico's API version
* *
* @see AbstractPlugin::checkCompatibility() * @see AbstractPicoPlugin::checkCompatibility()
* @var bool|null * @var bool|null
*/ */
protected $nativePlugin; protected $nativePlugin;
@ -63,8 +61,8 @@ abstract class AbstractPlugin implements PluginInterface
/** /**
* List of plugins which this plugin depends on * List of plugins which this plugin depends on
* *
* @see AbstractPlugin::checkDependencies() * @see AbstractPicoPlugin::checkDependencies()
* @see PluginInterface::getDependencies() * @see PicoPluginInterface::getDependencies()
* @var string[] * @var string[]
*/ */
protected $dependsOn = []; protected $dependsOn = [];
@ -72,8 +70,8 @@ abstract class AbstractPlugin implements PluginInterface
/** /**
* List of plugin which depend on this plugin * List of plugin which depend on this plugin
* *
* @see AbstractPlugin::checkDependants() * @see AbstractPicoPlugin::checkDependants()
* @see PluginInterface::getDependants() * @see PicoPluginInterface::getDependants()
* @var object[]|null * @var object[]|null
*/ */
protected $dependants; protected $dependants;
@ -198,7 +196,7 @@ abstract class AbstractPlugin implements PluginInterface
/** /**
* Enables all plugins which this plugin depends on * Enables all plugins which this plugin depends on
* *
* @see PluginInterface::getDependencies() * @see PicoPluginInterface::getDependencies()
* *
* @param bool $recursive enable required plugins automatically * @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 // plugins which don't implement PicoPluginInterface are always enabled
if (($plugin instanceof PluginInterface) && !$plugin->isEnabled()) { if (($plugin instanceof PicoPluginInterface) && !$plugin->isEnabled()) {
if ($recursive) { if ($recursive) {
if (!$plugin->isStatusChanged()) { if (!$plugin->isStatusChanged()) {
$plugin->setEnabled(true, true, true); $plugin->setEnabled(true, true, true);
@ -248,7 +246,7 @@ abstract class AbstractPlugin implements PluginInterface
/** /**
* Disables all plugins which depend on this plugin * Disables all plugins which depend on this plugin
* *
* @see PluginInterface::getDependants() * @see PicoPluginInterface::getDependants()
* *
* @param bool $recursive disabled dependant plugins automatically * @param bool $recursive disabled dependant plugins automatically
* *
@ -291,7 +289,7 @@ abstract class AbstractPlugin implements PluginInterface
$this->dependants = []; $this->dependants = [];
foreach ($this->getPico()->getPlugins() as $pluginName => $plugin) { foreach ($this->getPico()->getPlugins() as $pluginName => $plugin) {
// only plugins which implement PicoPluginInterface support dependencies // only plugins which implement PicoPluginInterface support dependencies
if ($plugin instanceof PluginInterface) { if ($plugin instanceof PicoPluginInterface) {
$dependencies = $plugin->getDependencies(); $dependencies = $plugin->getDependencies();
if (in_array(get_called_class(), $dependencies)) { if (in_array(get_called_class(), $dependencies)) {
$this->dependants[$pluginName] = $plugin; $this->dependants[$pluginName] = $plugin;

View File

@ -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

View File

@ -10,8 +10,6 @@
* License-Filename: LICENSE * License-Filename: LICENSE
*/ */
namespace picocms\Pico;
/** /**
* Common interface for Pico plugins * Common interface for Pico plugins
* *
@ -30,7 +28,7 @@ namespace picocms\Pico;
* @license http://opensource.org/licenses/MIT The MIT License * @license http://opensource.org/licenses/MIT The MIT License
* @version 3.0 * @version 3.0
*/ */
interface PluginInterface interface PicoPluginInterface
{ {
/** /**
* Handles a event that was triggered by Pico * Handles a event that was triggered by Pico
@ -43,8 +41,8 @@ interface PluginInterface
/** /**
* Enables or disables this plugin * Enables or disables this plugin
* *
* @see PluginInterface::isEnabled() * @see PicoPluginInterface::isEnabled()
* @see PluginInterface::isStatusChanged() * @see PicoPluginInterface::isStatusChanged()
* *
* @param bool $enabled enable (TRUE) or disable (FALSE) this plugin * @param bool $enabled enable (TRUE) or disable (FALSE) this plugin
* @param bool $recursive when TRUE, enable or disable recursively. * @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 * wasn't triggered on all plugins yet. This method might even return NULL
* then. The plugin's status might change later. * then. The plugin's status might change later.
* *
* @see PluginInterface::setEnabled() * @see PicoPluginInterface::setEnabled()
* *
* @return bool|null plugin is enabled (TRUE) or disabled (FALSE) * @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 * 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 * @return bool plugin is in its default state (TRUE), FALSE otherwise
*/ */

View File

@ -10,8 +10,6 @@
* License-Filename: LICENSE * License-Filename: LICENSE
*/ */
namespace picocms\Pico;
use Twig\Error\RuntimeError as TwigRuntimeError; use Twig\Error\RuntimeError as TwigRuntimeError;
use Twig\Extension\AbstractExtension as AbstractTwigExtension; use Twig\Extension\AbstractExtension as AbstractTwigExtension;
use Twig\Extension\ExtensionInterface as TwigExtensionInterface; use Twig\Extension\ExtensionInterface as TwigExtensionInterface;
@ -26,12 +24,12 @@ use Twig\TwigFunction;
* @license http://opensource.org/licenses/MIT The MIT License * @license http://opensource.org/licenses/MIT The MIT License
* @version 3.0 * @version 3.0
*/ */
class TwigExtension extends AbstractTwigExtension class PicoTwigExtension extends AbstractTwigExtension
{ {
/** /**
* Current instance of Pico * Current instance of Pico
* *
* @see TwigExtension::getPico() * @see PicoTwigExtension::getPico()
* @var Pico * @var Pico
*/ */
private $pico; private $pico;

View File

@ -10,7 +10,7 @@
* License-Filename: LICENSE * License-Filename: LICENSE
*/ */
use picocms\Pico\AbstractPlugin; use picocms\Pico\AbstractPicoPlugin;
use picocms\Pico\Pico; use picocms\Pico\Pico;
use Twig\Environment as TwigEnvironment; use Twig\Environment as TwigEnvironment;
@ -25,7 +25,7 @@ use Twig\Environment as TwigEnvironment;
* @license http://opensource.org/licenses/MIT The MIT License * @license http://opensource.org/licenses/MIT The MIT License
* @version 3.0 * @version 3.0
*/ */
class DummyPlugin extends AbstractPlugin class DummyPlugin extends AbstractPicoPlugin
{ {
/** /**
* API version used by this plugin * 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 * No matter what, the user can always explicitly enable or disable this
* plugin in Pico's config. * plugin in Pico's config.
* *
* @see AbstractPlugin::$enabled * @see AbstractPicoPlugin::$enabled
* @var bool|null * @var bool|null
*/ */
protected $enabled = false; protected $enabled = false;
@ -67,7 +67,7 @@ class DummyPlugin extends AbstractPlugin
* If your plugin doesn't depend on any other plugin, remove this class * If your plugin doesn't depend on any other plugin, remove this class
* property. * property.
* *
* @see AbstractPlugin::$dependsOn * @see AbstractPicoPlugin::$dependsOn
* @var string[] * @var string[]
*/ */
protected $dependsOn = array(); protected $dependsOn = array();