Example #1
0
 /**
  * Initialize method
  * 
  * @param AclComponent $Component Component instance 
  * @return void
  */
 public function initialize(Component $Component)
 {
     parent::initialize($Component);
     App::uses('PhpReader', 'Configure');
     $Reader = new PhpReader(dirname($this->options['config']) . DS);
     $config = $Reader->read(basename($this->options['config']));
     $Component->Config = $config;
 }
Example #2
0
 /**
  * Initialize method
  * 
  * @param AclComponent $Component Component instance 
  * @return void
  */
 public function initialize(Component $Component)
 {
     if (!empty($Component->settings['adapter'])) {
         $this->options = array_merge($this->options, $Component->settings['adapter']);
     }
     App::uses('PhpReader', 'Configure');
     $Reader = new PhpReader(dirname($this->options['config']) . DS);
     $config = $Reader->read(basename($this->options['config']));
     $this->build($config);
     $Component->Aco = $this->Aco;
     $Component->Aro = $this->Aro;
 }
 /**
  * test reading from plugins
  *
  * @return void
  */
 function testReadPluginValue()
 {
     App::build(array('plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)), true);
     $reader = new PhpReader($this->path);
     $result = $reader->read('TestPlugin.load');
     $this->assertTrue(isset($result['plugin_load']));
 }
 /**
  * Reads a plugin dashboard setting and store them under $_settingKey
  *
  * @param string $key Configuration key name
  * @return array
  */
 public function read($key)
 {
     $config = parent::read($key);
     $defaults = array('title' => false, 'weight' => 9999, 'element' => false, 'cache' => true, 'access' => array(), 'column' => false, 'collapsed' => false);
     $settings = array();
     foreach ($config as $alias => $setting) {
         $alias = Inflector::slug($alias, '-');
         $setting = Hash::merge($defaults, $setting);
         $settings[$alias] = $setting;
     }
     $result = array($this->_settingKey => $settings);
     return $result;
 }
Example #5
0
 /**
  * Test that dump() makes files read() can read.
  *
  * @return void
  */
 public function testDumpRead()
 {
     $reader = new PhpReader(TMP);
     $reader->dump('test.php', $this->testData);
     $result = $reader->read('test.php');
     unlink(TMP . 'test.php');
     $this->assertEquals($this->testData, $result);
 }
 /**
  * test reading from plugins
  *
  * @return void
  */
 public function testReadPluginValue()
 {
     App::build(array('plugins' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS)), true);
     CakePlugin::load('TestPlugin');
     $reader = new PhpReader($this->path);
     $result = $reader->read('TestPlugin.load');
     $this->assertTrue(isset($result['plugin_load']));
     $result = $reader->read('TestPlugin.load.php');
     $this->assertTrue(isset($result['plugin_load']));
     CakePlugin::unload();
 }
Example #7
0
 /**
  * Load a config file containing templates.
  *
  * Template files should define a `$config` variable containing
  * all the templates to load. Loaded templates will be merged with existing
  * templates.
  *
  * @param string $file The file to load
  * @return void
  */
 public function load($file)
 {
     $loader = new PhpReader();
     $templates = $loader->read($file);
     $this->add($templates);
 }