Split PicoDeprecated::onConfigLoaded() into multiple methods
This commit is contained in:
parent
46ef63186a
commit
1cbf48af79
@ -84,19 +84,34 @@ class PicoDeprecated extends AbstractPicoPlugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Triggers the deprecated event config_loaded($config), tries to read
|
* Triggers the deprecated event config_loaded($config)
|
||||||
* {@path "config.php"} in Picos root dir, enables the plugins
|
|
||||||
* {@link PicoParsePagesContent} and {@link PicoExcerpt} and defines some
|
|
||||||
* deprecated constants (ROOT_DIR, CONTENT_DIR etc.)
|
|
||||||
*
|
*
|
||||||
|
* @see PicoDeprecated::defineConstants()
|
||||||
|
* @see PicoDeprecated::loadRootDirConfig()
|
||||||
|
* @see PicoDeprecated::enablePlugins()
|
||||||
* @see DummyPlugin::onConfigLoaded()
|
* @see DummyPlugin::onConfigLoaded()
|
||||||
*/
|
*/
|
||||||
public function onConfigLoaded(&$config)
|
public function onConfigLoaded(&$config)
|
||||||
{
|
{
|
||||||
// CONTENT_DIR constant is deprecated since v0.9,
|
$this->defineConstants();
|
||||||
// ROOT_DIR, LIB_DIR, PLUGINS_DIR, THEMES_DIR and CONTENT_EXT constants since v1.0,
|
$this->loadRootDirConfig($config);
|
||||||
// CONFIG_DIR constant existed just for a short time between v0.9 and v1.0,
|
$this->enablePlugins();
|
||||||
// CACHE_DIR constant was dropped with v1.0 without a replacement
|
|
||||||
|
$this->triggerEvent('config_loaded', array(&$config));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines deprecated constants
|
||||||
|
*
|
||||||
|
* CONTENT_DIR is deprecated since v0.9, ROOT_DIR, LIB_DIR, PLUGINS_DIR,
|
||||||
|
* THEMES_DIR and CONTENT_EXT since v1.0, CONFIG_DIR existed just for a
|
||||||
|
* short time between v0.9 and v1.0 and CACHE_DIR was dropped with v1.0
|
||||||
|
* without a replacement.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function defineConstants()
|
||||||
|
{
|
||||||
if (!defined('ROOT_DIR')) {
|
if (!defined('ROOT_DIR')) {
|
||||||
define('ROOT_DIR', $this->getRootDir());
|
define('ROOT_DIR', $this->getRootDir());
|
||||||
}
|
}
|
||||||
@ -114,12 +129,21 @@ class PicoDeprecated extends AbstractPicoPlugin
|
|||||||
define('THEMES_DIR', $this->getThemesDir());
|
define('THEMES_DIR', $this->getThemesDir());
|
||||||
}
|
}
|
||||||
if (!defined('CONTENT_DIR')) {
|
if (!defined('CONTENT_DIR')) {
|
||||||
define('CONTENT_DIR', $config['content_dir']);
|
define('CONTENT_DIR', $this->getConfig('content_dir'));
|
||||||
}
|
}
|
||||||
if (!defined('CONTENT_EXT')) {
|
if (!defined('CONTENT_EXT')) {
|
||||||
define('CONTENT_EXT', $config['content_ext']);
|
define('CONTENT_EXT', $this->getConfig('content_ext'));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read {@path "config.php"} in Picos root dir
|
||||||
|
*
|
||||||
|
* @param array &$config array of config variables
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function loadRootDirConfig(&$config)
|
||||||
|
{
|
||||||
if (file_exists($this->getRootDir() . 'config.php')) {
|
if (file_exists($this->getRootDir() . 'config.php')) {
|
||||||
// config.php in Pico::$rootDir is deprecated; use Pico::$configDir instead
|
// config.php in Pico::$rootDir is deprecated; use Pico::$configDir instead
|
||||||
$newConfig = require($this->getRootDir() . 'config.php');
|
$newConfig = require($this->getRootDir() . 'config.php');
|
||||||
@ -127,7 +151,15 @@ class PicoDeprecated extends AbstractPicoPlugin
|
|||||||
$config = $newConfig + $config;
|
$config = $newConfig + $config;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables the plugins {@link PicoParsePagesContent} and {@link PicoExcerpt}
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function enablePlugins()
|
||||||
|
{
|
||||||
// enable PicoParsePagesContent and PicoExcerpt
|
// enable PicoParsePagesContent and PicoExcerpt
|
||||||
// we can't enable them during onPluginsLoaded because we can't know
|
// we can't enable them during onPluginsLoaded because we can't know
|
||||||
// if the user disabled us (PicoDeprecated) manually in the config
|
// if the user disabled us (PicoDeprecated) manually in the config
|
||||||
@ -145,8 +177,6 @@ class PicoDeprecated extends AbstractPicoPlugin
|
|||||||
$plugins['PicoExcerpt']->setEnabled(true, true, true);
|
$plugins['PicoExcerpt']->setEnabled(true, true, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->triggerEvent('config_loaded', array(&$config));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user