You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4php-dev@logging.apache.org by gr...@apache.org on 2009/05/24 01:11:55 UTC

svn commit: r778061 - in /incubator/log4php/trunk/src/main/php: LoggerReflectionUtils.php configurators/LoggerConfiguratorXml.php

Author: grobmeier
Date: Sat May 23 23:11:55 2009
New Revision: 778061

URL: http://svn.apache.org/viewvc?rev=778061&view=rev
Log:
moved setter method to reflectionutils

Modified:
    incubator/log4php/trunk/src/main/php/LoggerReflectionUtils.php
    incubator/log4php/trunk/src/main/php/configurators/LoggerConfiguratorXml.php

Modified: incubator/log4php/trunk/src/main/php/LoggerReflectionUtils.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/LoggerReflectionUtils.php?rev=778061&r1=778060&r2=778061&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/LoggerReflectionUtils.php (original)
+++ incubator/log4php/trunk/src/main/php/LoggerReflectionUtils.php Sat May 23 23:11:55 2009
@@ -134,6 +134,25 @@
 		}
 		return null;
 	}
+	
+	/**
+     * @param object $object
+     * @param string $name
+     * @param mixed $value
+     */
+    function setter(&$object, $name, $value) {
+    	// TODO: check if this can be replaced with LoggerReflectionUtils
+        if (empty($name)) {
+            return false;
+        }
+        $methodName = 'set'.ucfirst($name);
+        if (method_exists($object, $methodName)) {
+            return call_user_func(array(&$object, $methodName), $value);
+        } else {
+            return false;
+        }
+    }
+	
 }
  
  ?>
\ No newline at end of file

Modified: incubator/log4php/trunk/src/main/php/configurators/LoggerConfiguratorXml.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/configurators/LoggerConfiguratorXml.php?rev=778061&r1=778060&r2=778061&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/configurators/LoggerConfiguratorXml.php (original)
+++ incubator/log4php/trunk/src/main/php/configurators/LoggerConfiguratorXml.php Sat May 23 23:11:55 2009
@@ -371,17 +371,17 @@
                 switch (end($this->state)) {
                     case LOG4PHP_LOGGER_DOM_CONFIGURATOR_APPENDER_STATE:
                         if ($this->appender !== null) {
-                            $this->setter($this->appender, $this->subst($attribs['NAME']), $this->subst($attribs['VALUE']));
+                            LoggerReflectionUtils::setter($this->appender, $this->subst($attribs['NAME']), $this->subst($attribs['VALUE']));
                         }
                         break;
                     case LOG4PHP_LOGGER_DOM_CONFIGURATOR_LAYOUT_STATE:
                         if ($this->layout !== null) {
-                            $this->setter($this->layout, $this->subst($attribs['NAME']), $this->subst($attribs['VALUE']));                
+                            LoggerReflectionUtils::setter($this->layout, $this->subst($attribs['NAME']), $this->subst($attribs['VALUE']));                
                         }
                         break;
                     case LOG4PHP_LOGGER_DOM_CONFIGURATOR_FILTER_STATE:
                         if ($this->filter !== null) {
-                            $this->setter($this->filter, $this->subst($attribs['NAME']), $this->subst($attribs['VALUE']));
+                            LoggerReflectionUtils::setter($this->filter, $this->subst($attribs['NAME']), $this->subst($attribs['VALUE']));
                         }
                         break;
                     default:
@@ -470,25 +470,6 @@
         }
     }
     
-    /**
-     * @param object $object
-     * @param string $name
-     * @param mixed $value
-     */
-    function setter(&$object, $name, $value)
-    {
-    	// TODO: check if this can be replaced with LoggerReflectionUtils
-        if (empty($name)) {
-            return false;
-        }
-        $methodName = 'set'.ucfirst($name);
-        if (method_exists($object, $methodName)) {
-            return call_user_func(array(&$object, $methodName), $value);
-        } else {
-            return false;
-        }
-    }
-    
     function subst($value)
     {
         return LoggerOptionConverter::substVars($value);