/** * Gets the 'annotations.parser' service. * * This service is shared. * This method always returns the same instance of the service. * * @return Doctrine\Common\Annotations\Parser A Doctrine\Common\Annotations\Parser instance. */ protected function getAnnotations_ParserService() { $this->services['annotations.parser'] = $instance = new \Doctrine\Common\Annotations\Parser(); $instance->setAutoloadAnnotations(true); $instance->setAnnotationNamespaceAlias('Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\', 'extra'); return $instance; }
/** * Gets the annotations applied to a method. * * @param string|ReflectionClass $class The name or ReflectionClass of the class that owns the method. * @param string|ReflectionMethod $property The name or ReflectionMethod of the method from which * the annotations should be read. * @return array An array of Annotations. */ public function getMethodAnnotations(ReflectionMethod $method) { $cacheKey = $method->getDeclaringClass()->getName() . '#' . $method->getName() . self::$CACHE_SALT; if ($this->_cache->contains($cacheKey)) { return $this->_cache->fetch($cacheKey); } $context = "method " . $method->getDeclaringClass()->getName() . "::" . $method->getName() . "()"; $annotations = $this->_parser->parse($method->getDocComment(), $context); $this->_cache->save($cacheKey, $annotations, null); return $annotations; }
/** * Gets the annotations applied to a method. * * @param ReflectionMethod $property The name or ReflectionMethod of the method from which * the annotations should be read. * @return array An array of Annotations. */ public function getMethodAnnotations(ReflectionMethod $method) { $cacheKey = $method->getDeclaringClass()->getName() . '#' . $method->getName() . self::$CACHE_SALT; // Attempt to grab data from cache if (($data = $this->cache->fetch($cacheKey)) !== false) { return $data; } $context = 'method ' . $method->getDeclaringClass()->getName() . '::' . $method->getName() . '()'; $annotations = $this->parser->parse($method->getDocComment(), $context); $this->cache->save($cacheKey, $annotations, null); return $annotations; }
/** * Gets the annotations applied to a method. * * @param string|ReflectionClass $class The name or ReflectionClass of the class that owns the method. * @param string|ReflectionMethod $property The name or ReflectionMethod of the method from which * the annotations should be read. * @return array An array of Annotations. */ public function getMethodAnnotations(ReflectionMethod $method) { $cacheKey = $method->getDeclaringClass()->getName() . '#' . $method->getName() . self::$CACHE_SALT; //FIXME: Just use ->fetch(), otherwise some drivers, i.e. APC will fetch twice because they // implement contains() in terms of fetch(), *sigh*. if ($this->_cache->contains($cacheKey)) { return $this->_cache->fetch($cacheKey); } $context = "method " . $method->getDeclaringClass()->getName() . "::" . $method->getName() . "()"; $annotations = $this->_parser->parse($method->getDocComment(), $context); $this->_cache->save($cacheKey, $annotations, null); return $annotations; }