/** * @param $class_name string * @param $search array * @return array */ private function createArrayReference($class_name, $search) { $array = isset($search) ? [Builder::fromArray($class_name, $search)] : null; $class = new Link_Class($class_name); $link_class = $class->getAnnotation('link')->value; if ($link_class) { $object = reset($array); $link_search = Builder::create($link_class); $composite_property_name = $class->getCompositeProperty()->name; foreach (array_keys($class->getLinkedProperties()) as $property_name) { if (isset($search[$property_name])) { $link_search->{$property_name} = $search[$property_name]; } } $object->{$composite_property_name} = Dao::searchOne($link_search) ?: $link_search; } return $array; }
/** * @param $encoded_string string * @param $class_name string * @return array|object */ public function decodeObject($encoded_string, $class_name = null) { return isset($class_name) ? Builder::fromArray($class_name, json_decode($encoded_string, true)) : json_decode($encoded_string); }