/** * Annotations specifically related to Entity Transformation as defined in the TransformMapping class * * @param $class * @return null | TransformMapping */ public function getTransformAnnotations($class) { $annotations = $this->reader->getClassAnnotations(new \ReflectionClass($class)); foreach ($annotations as $annotation) { if ($annotation instanceof TransformMapping) { return $annotation; } } return null; }
/** * Annotations specifically related to Entity Transformation as defined in the Proxy class * * @param $class * @return null | Proxy */ public function getProxyAnnotations($class) { if ($this->doctrineProxyResolver->isDoctrineProxy($class)) { $class = $this->doctrineProxyResolver->unwrapDoctrineProxyClass($class); } $annotations = $this->reader->getClassAnnotations(new \ReflectionClass($class)); foreach ($annotations as $annotation) { if ($annotation instanceof Proxy) { return $annotation; } } return null; }
public function testIgnoresStaleCache() { $file = __DIR__ . '/Fixtures/Controller.php'; touch($file); $name = 'Doctrine\\Tests\\Common\\Annotations\\Fixtures\\Controller'; $cacheKey = $name . '@[Annot]'; $cache = $this->getMock('Doctrine\\Common\\Cache\\Cache'); $cache->expects($this->at(0))->method('fetch')->with($this->equalTo($cacheKey))->will($this->returnValue(array())); $cache->expects($this->at(1))->method('fetch')->with($this->equalTo('[C]' . $cacheKey))->will($this->returnValue(time() - 10)); $cache->expects($this->at(2))->method('save')->with($this->equalTo($cacheKey)); $cache->expects($this->at(3))->method('save')->with($this->equalTo('[C]' . $cacheKey)); $reader = new CachedReader(new AnnotationReader(), $cache, true); $this->assertEquals(array(new Route(array('value' => '/someprefix'))), $reader->getClassAnnotations(new \ReflectionClass($name))); }