public function setUp() { $chips_default = $this->mock('Grok')->setReturnValue('dispatch', 'alternate_default_called')->construct(); $chip = $this->mock('Chippino_Factory')->setReturnValue('retrieve', $chips_default, array(new Snap_Equals_Expectation('Chips/Default'), new Snap_Anything_Expectation(), new Snap_Anything_Expectation()))->construct(); chippino_config()->chippino_class = get_class($chip); chippino_config()->base_path = dirname(__FILE__) . DIRECTORY_SEPARATOR; }
function chippino($settings) { // set defaults if not set $settings = array_merge(array('base_path' => dirname(__FILE__) . DIRECTORY_SEPARATOR . 'apps/chippino', 'chippino_class' => 'Chippino_Factory'), $settings); if (!isset($settings['config_path'])) { $settings['config_path'] = $settings['base_path'] . DIRECTORY_SEPARATOR . 'config'; } // do any special formatting per setting foreach ($settings as $key => $value) { switch ($key) { case 'base_path': case 'config_path': $value = substr($value, strrpos($value, DIRECTORY_SEPARATOR)) === DIRECTORY_SEPARATOR ? $value : $value . DIRECTORY_SEPARATOR; $value = substr($value, 0, -1); $settings[$key] = $value; break; } // assign to framework config chippino_config()->{$key} = $value; } // all done, execute chip('#Chippino/Core/Init')->with(); }
<?php /** * Chippino MVC Config Loader * Reads the config directory and returns a properly namespaced set of results * for performance, this should be called asSingleton() **/ // if asSingleton is enabled, this will get set if (isset($this->config_results)) { return $this->config_results; } $path = chippino_config()->config_path; $config = array(); $handle = opendir($path); while (FALSE !== ($file = readdir($handle))) { // skip files starting with . if (substr($file, 0, 1) == '.') { continue; } // skip directories if (is_dir($file)) { continue; } // skip things not ending in .php if (substr($file, -4) != '.php') { continue; } // strip ending .php, add to configs $file = substr($file, 0, -4); $default = file_exists(chip('#Chippino/Config/' . $file)->getFilePath() . '.php') ? chip('#Chippino/Config/' . $file)->with() : array(); $loaded = chip('!' . $path . '/' . $file)->with();
public function __construct($caller, $callee) { // strip base path from both $caller = strtolower(str_replace(array(chippino_config()->base_path, '.php'), '', $caller)); $callee = strtolower(str_replace(array(chippino_config()->base_path, '.php'), '', $callee)); parent::__construct('Access error: Attempt to call ' . $caller . ' from ' . $callee); }