From b09433a37b6b4f1813ce322894496df01c0706a0 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Tue, 6 Oct 2015 20:38:34 +0200 Subject: [PATCH] Allow multiple calls to Pico::setConfig() --- lib/Pico.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/Pico.php b/lib/Pico.php index 61399e5..5070471 100644 --- a/lib/Pico.php +++ b/lib/Pico.php @@ -78,6 +78,13 @@ class Pico */ protected $themesDir; + /** + * Boolean indicating whether Picos processing started yet + * + * @var boolean + */ + protected $locked = false; + /** * List of loaded plugins * @@ -246,8 +253,8 @@ class Pico */ public function run() { - // lock config - $this->config = is_array($this->config) ? $this->config : array(); + // lock Pico + $this->locked = true; // load plugins $this->loadPlugins(); @@ -421,6 +428,8 @@ class Pico $configFile = $this->getConfigDir() . 'config.php'; $config = file_exists($configFile) ? require($configFile) : null; + + $this->config = is_array($this->config) ? $this->config : array(); $this->config += is_array($config) ? $config + $defaultConfig : $defaultConfig; if (empty($this->config['base_url'])) { @@ -456,7 +465,7 @@ class Pico */ public function setConfig(array $config) { - if ($this->config !== null) { + if ($this->locked) { throw new RuntimeException('You cannot modify Picos config after processing has started'); }