Exemple #1
0
 /**
  * @depends testGetXmlRootObj
  */
 public function testConfigureBySection($pSection)
 {
     $test = new testClass();
     $this->assertEquals('', $test->LOGFILE);
     \Savant\CConfigure::configureBySection($test, $pSection->configurations->default);
     $this->assertEquals('bronckotest.log', $test->LOGFILE);
 }
Exemple #2
0
 /**
  * invoke before constructor is called
  * @param IConfigure $pObj
  * @param AOP\AJoinPoint $pJoinPoint
  */
 public static function onBeforeConstructor(&$pObj, AOP\AJoinPoint $pJoinPoint)
 {
     if (!$pObj instanceof \Savant\IConfigure) {
         return;
     }
     if (\method_exists($pObj, 'configure')) {
         $pObj->configure($pObj->confSection);
         return;
     }
     $class = \get_class($pObj);
     try {
         $config = $pObj->config = CConfigure::getClassConfig($class, $pObj->confSection);
     } catch (\Savant\EConfigure $e) {
         return;
     }
     foreach ($config->member as $memberElement) {
         try {
             $propObj = new \ReflectionProperty($class, \strtoupper($memberElement->attributes()->name));
             $propObj->setValue($pObj, $memberElement);
         } catch (ReflectionException $e) {
             return;
         }
     }
 }
Exemple #3
0
 /**
  * configure database object from datasources
  * @param string $pSection
  */
 public function configure($pSection = 'default')
 {
     $config = \Savant\CConfigure::load($this->confFile);
     $section = $config->datasources->xpath("//datasource[@name='" . $pSection . "']");
     foreach (\Savant\CConfigure::getConfigFromSection($section[0]) as $configVar => $configVal) {
         $this->{\strtoupper($configVar)} = $configVal;
     }
 }