public function __construct(Url $url) { if (!$url->isComplex()) { throw new RuntimeException("Invalid constructor"); } foreach (get_object_vars($url) as $key => $value) { $this->{$key} = $value; } foreach ($this->parts as $part) { $part->setIndex('$i'); } }
protected function getUrl($routeAnnotation, $route, $args = array()) { $url = new Url($routeAnnotation); if (!empty($route)) { $url->setRoute($route); } if (isset($args['set'])) { $url->setArguments($args['set']); } if (!empty($args[1]) || !empty($args['name'])) { $url->setName(empty($args[1]) ? $args['name'] : $args[1]); } $base = 0; foreach ($this->all_filters as $type => $filters) { foreach ($filters as $filter) { $url->addFilter($type, $filter[0], array(), $filter[1] + ++$base); } } $filters = (array) $routeAnnotation; if ($routeAnnotation->isMethod()) { $class = $this->annotations->getClassInfo($routeAnnotation['class']); if (!empty($class['class'])) { $filters = array_merge((array) $class['class'], $filters); } } foreach ($filters as $annotation) { $name = strtolower($annotation['method']); if (!empty($this->route_filters[$name])) { foreach ($this->route_filters[$name] as $filter) { $url->addFilter($filter[0], $filter[1], $annotation['args'], $filter[2] + ++$base); } } } return $url; }
protected function getUrl($routeAnnotation, $route, $args = array()) { $url = new Url($routeAnnotation, $this); $url->setRouteAndArgs($route, $args); $base = $url->addFilters($this->allFilterss); $filters = iterator_to_array($routeAnnotation->GetParent()); if ($routeAnnotation->isMethod()) { $classAnn = $routeAnnotation->getObject()->getClass()->get(''); $filters = array_merge($classAnn, $filters); } $url->addFiltersFromAnnotations($this->routeFilters, $filters, $base); return $url; }