示例#1
0
 /**
  * Tests toArray method
  *
  * @author kjdev
  * @since  2013-07-18
  */
 public function testConfigToArray()
 {
     $this->specify("Transform Config to the array does not returns the expected result", function () {
         $expected = ['test' => ['parent' => ['property' => 1, 'property2' => 'yeah', 'property3' => ['baseuri' => '/phalcon/'], 'property4' => ['models' => ['metadata' => 'memory']], 'property5' => ['database' => ['adapter' => 'mysql', 'host' => 'localhost', 'username' => 'user', 'password' => 'passwd', 'name' => 'demo']], 'property6' => ['test' => ['a', 'b', 'c']]]]];
         $config = new Ini(PATH_DATA . 'config/directive.ini');
         expect($config->toArray())->equals($expected);
     });
 }
示例#2
0
 /**
  * Registers services related to the module
  *
  * @param DiInterface $di
  */
 public function registerServices(DiInterface $di)
 {
     /**
      * Read configuration
      */
     $config = new Ini(APP_PATH . "/apps/admin/config/config.ini");
     /**
      * Setting up the view component
      */
     $di['view'] = function () {
         $view = new View();
         $view->setViewsDir(__DIR__ . '/views/');
         return $view;
     };
     /**
      * Database connection is created based in the parameters defined in the configuration file
      */
     $di['db'] = function () use($config) {
         return new DbAdapter($config->toArray());
     };
 }