Ejemplo n.º 1
0
 public function testParseConfigTree()
 {
     $configTree = array("section1" => array("type1" => 1, "type2" => array("subtype1" => 'value', "subtype2" => 'value'), "type3" => "testValue"), "section2" => array("type1" => 1));
     $configList = Config::parseConfigTree($configTree);
     $expected = array('section1.type1' => 1, 'section1.type2.subtype1' => 'value', 'section1.type2.subtype2' => 'value', 'section1.type3' => 'testValue', 'section2.type1' => 1);
     $this->assertEquals($expected, $configList);
 }
Ejemplo n.º 2
0
 /**
  * Loads the defined modules from the Zibo Configuration
  * @param zibo\core\Zibo $zibo Instance of Zibo
  * @return array Array with the defined modules
  * @throws zibo\ZiboException when a module could not be created
  * @see Module
  * @see CONFIG_MODULE
  */
 public function loadModules(Zibo $zibo)
 {
     $configModules = $zibo->getConfigValue(self::CONFIG_MODULE);
     if (!$configModules) {
         return array();
     }
     $objectFactory = new ObjectFactory();
     $modules = array();
     $configModules = Config::parseConfigTree($configModules);
     foreach ($configModules as $configKey => $moduleClass) {
         try {
             $modules[] = $objectFactory->create($moduleClass, self::INTERFACE_MODULE);
         } catch (ZiboException $exception) {
             throw new ZiboException('Could not create ' . $moduleClass . ' from the ' . $configKey . ' configuration key', 0, $exception);
         }
     }
     return $modules;
 }