public function testStaticArraySet()
 {
     $arr['xxxname'] = 'Joe';
     $arr['xxxmale'] = true;
     $s = new Simple();
     LoggerReflectionUtils::setPropertiesByObject($s, $arr, "xxx");
     $this->assertEquals($s->getName(), 'Joe');
     $this->assertEquals($s->isMale(), true);
 }
Exemplo n.º 2
0
 /**
  * @param array $props array of properties
  * @param string $appenderName
  * @return LoggerAppender
  */
 private function parseAppender($props, $appenderName)
 {
     $appender = LoggerAppenderPool::getAppenderFromPool($appenderName);
     $prefix = self::APPENDER_PREFIX . $appenderName;
     if ($appender === null) {
         // Appender was not previously initialized.
         $appenderClass = @$props[$prefix];
         $appender = LoggerAppenderPool::getAppenderFromPool($appenderName, $appenderClass);
         if ($appender === null) {
             return null;
         }
     }
     if ($appender->requiresLayout()) {
         $layoutPrefix = $prefix . ".layout";
         $layoutClass = @$props[$layoutPrefix];
         $layoutClass = LoggerOptionConverter::substVars($layoutClass, $props);
         if (empty($layoutClass)) {
             $layout = LoggerReflectionUtils::createObject('LoggerLayoutSimple');
         } else {
             $layout = LoggerReflectionUtils::createObject($layoutClass);
             if ($layout === null) {
                 $layout = LoggerReflectionUtils::createObject('LoggerLayoutSimple');
             }
         }
         LoggerReflectionUtils::setPropertiesByObject($layout, $props, $layoutPrefix . ".");
         $appender->setLayout($layout);
     }
     LoggerReflectionUtils::setPropertiesByObject($appender, $props, $prefix . ".");
     return $appender;
 }