/** * Matches the url against the given page. * * @param string $url The URL. * @param Page $page Page to match. * * @return boolean */ public function match($url, Page $page) { foreach ($this->matchers as $page_url_matcher) { $annotation_name = '@' . $page_url_matcher->getAnnotationName(); $annotations = $this->annotationManager->getClassAnnotations($page, $annotation_name); if (!$annotations) { continue; } $this->ensureAnnotationsAreValid($annotations, $annotation_name); if ($page_url_matcher->matches($url, $annotations)) { return true; } } return false; }
/** * Returns annotations defined at property or in class, set in `@var` annotation of a property. * * @param string $annotation_class Annotation name. * * @return IAnnotation[] */ public function getAnnotationsFromPropertyOrClass($annotation_class) { $annotations = $this->getAnnotations($annotation_class); if (!$annotations) { $annotations = $this->annotationManager->getClassAnnotations($this->getDataType(), $annotation_class); } return $annotations; }
/** * Initializes the page. * * @param Page $page Page to initialize. * * @return self */ public function initPage(Page $page) { /* @var $annotations PageUrlAnnotation[] */ $annotations = $this->annotationManager->getClassAnnotations($page, '@page-url'); if (!$annotations || !$annotations[0] instanceof PageUrlAnnotation) { return $this; } $page->setUrlBuilder($this->urlFactory->getBuilder($this->urlNormalizer->normalize($annotations[0]))); return $this; }
/** * Initializes the page. * * @param Page $page Page to initialize. * * @return self */ public function initPage(Page $page) { /* @var $annotations PageUrlAnnotation[] */ $annotations = $this->annotationManager->getClassAnnotations($page, '@page-url'); if (empty($annotations)) { return $this; } $page->setUrlBuilder($this->urlBuilderFactory->getUrlBuilder($annotations[0]->url, $annotations[0]->params, $this->config->getOption('base_url'))); return $this; }
protected function testAnnotationManagerWithoutCache() { $this->setExpectedException(self::ANNOTATION_EXCEPTION, 'AnnotationManager::$cache is not configured'); $annotationManager = new AnnotationManager(); $annotationManager->getClassAnnotations('NoteAnnotation'); }