Esempio n. 1
0
 private static function loadArray($object, &$result, $prefix = "")
 {
     $reflect = new ReflectionClass($object);
     $typeName = $reflect->getName();
     $properties = ObjectParser::getProperties($object);
     if (is_array($properties)) {
         foreach ($properties as $key => $prop) {
             $propertyName = $prop->getName();
             $propNameCamelCase = ucfirst($propertyName);
             $getMethodName = "get{$propNameCamelCase}";
             $setMethodName = "set{$propNameCamelCase}";
             $setIdMethodName = "{$setMethodName}_id";
             $setMethodParameter = new ReflectionParameter(array($typeName, $setMethodName), 0);
             if ($reflect->getMethod($setMethodName) && $setMethodParameter->getClass() && method_exists($object, $setIdMethodName)) {
                 continue;
             }
             $value = $object->{$getMethodName}();
             $name = $prefix . $propertyName;
             if (is_object($value)) {
                 ObjectParser::loadArray($value, $result, "{$name}.");
             } else {
                 $result[$name] = $value;
             }
         }
         return true;
     }
     return false;
 }