/** * Generic getter for an object * * @param $stored mixed actual value of the object, or identifier to an object, or null * @param $class_name string the object class name * @param $object object the parent object * @param $property string|Reflection_Property the parent property * @return object */ public static function getObject(&$stored, $class_name, $object = null, $property = null) { if (!(self::$ignore || is_object($stored))) { if ($property instanceof Reflection_Property) { $property_name = $property->name; } elseif (is_string($property) && is_object($object)) { $property_name = $property; $property = new Reflection_Property(get_class($object), $property_name); } if (is_object($object) && isset($property_name)) { $id_property_name = 'id_' . $property_name; if (isset($object->{$id_property_name})) { $stored = $object->{$id_property_name}; } } if (isset($stored)) { if (isset($property) && $property->getAnnotation('store')->value == 'string') { /** @var $stored_object Stringable */ $stored_object = Builder::create($property->getType()->asString()); $stored_object->fromString($stored); $stored = $stored_object; } else { $stored = isset($property) && ($dao = $property->getAnnotation('dao')->value) ? Dao::get($dao)->read($stored, $class_name) : Dao::read($stored, $class_name); } } } return $stored; }