/**
  * Create open graph object
  */
 public function build()
 {
     $annotationReader = $this->annotationReader;
     if (null === $annotationReader) {
         $annotationReader = new AnnotationReader();
         if (null !== $this->cacheDirectory) {
             $cacheDirectory = sprintf('%s/annotations', $this->cacheDirectory);
             $this->createDirectory($cacheDirectory);
             $annotationReader = new CachedReader($annotationReader, new FilesystemCache($cacheDirectory));
         }
     }
     $metadataDriver = $this->driverFactory->createDriver($this->metadataDirectories, $annotationReader);
     $metadataFactory = new MetadataFactory($metadataDriver, null, $this->debug);
     $metadataFactory->setIncludeInterfaces($this->includeInterfaceMetadata);
     if (null !== $this->cacheDirectory) {
         $directory = sprintf('%s/metadata', $this->cacheDirectory);
         $this->createDirectory($directory);
         $metadataFactory->setCache(new FileCache($directory));
     }
     return new OpenGraphGenerator($metadataFactory);
 }
예제 #2
0
 public function build()
 {
     $annotationReader = $this->annotationReader;
     if (null === $annotationReader) {
         $annotationReader = new AnnotationReader();
         if (null !== $this->cacheDir) {
             $this->createDir($this->cacheDir . '/annotations');
             $annotationReader = new FileCacheReader($annotationReader, $this->cacheDir . '/annotations', $this->debug);
         }
     }
     $metadataDriver = $this->driverFactory->createDriver($this->metadataDirs, $annotationReader);
     $metadataFactory = new MetadataFactory($metadataDriver, null, $this->debug);
     $metadataFactory->setIncludeInterfaces($this->includeInterfaceMetadata);
     if (null !== $this->cacheDir) {
         $this->createDir($this->cacheDir . '/metadata');
         $metadataFactory->setCache(new FileCache($this->cacheDir . '/metadata'));
     }
     if (!$this->handlersConfigured) {
         $this->addDefaultHandlers();
     }
     if (!$this->listenersConfigured) {
         $this->addDefaultListeners();
     }
     if (!$this->visitorsAdded) {
         $this->addDefaultSerializationVisitors();
         $this->addDefaultDeserializationVisitors();
     }
     return new Serializer($metadataFactory, $this->handlerRegistry, $this->objectConstructor ?: new UnserializeObjectConstructor(), $this->serializationVisitors, $this->deserializationVisitors, $this->eventDispatcher);
 }
예제 #3
0
 private function buildMetadataFactory()
 {
     $annotationReader = $this->annotationReader;
     if (null === $annotationReader) {
         $annotationReader = new AnnotationReader();
         if (null !== $this->cacheDir) {
             $this->createDir($this->cacheDir . '/annotations');
             $annotationReader = new FileCacheReader($annotationReader, $this->cacheDir . '/annotations', $this->debug);
         }
     }
     if (!empty($this->metadataDirs)) {
         $fileLocator = new FileLocator($this->metadataDirs);
         $metadataDriver = new DriverChain(array(new YamlDriver($fileLocator), new XmlDriver($fileLocator), new AnnotationDriver($annotationReader)));
     } else {
         $metadataDriver = new AnnotationDriver($annotationReader);
     }
     $metadataDriver = new ExtensionDriver($metadataDriver, $this->configurationExtensions);
     $metadataFactory = new MetadataFactory($metadataDriver, null, $this->debug);
     $metadataFactory->setIncludeInterfaces($this->includeInterfaceMetadata);
     if (null !== $this->cacheDir) {
         $this->createDir($this->cacheDir . '/metadata');
         $metadataFactory->setCache(new FileCache($this->cacheDir . '/metadata'));
     }
     return $metadataFactory;
 }
 private function getFactory()
 {
     $factory = new MetadataFactory(new AnnotationDriver(new AnnotationReader()));
     $factory->setIncludeInterfaces(true);
     return $factory;
 }
예제 #5
0
 public function testGetMetadataWithInterfaces()
 {
     $driver = $this->getMock('Metadata\\Driver\\DriverInterface');
     $driver->expects($this->at(3))->method('loadMetadataForClass')->with($this->equalTo(new \ReflectionClass('Metadata\\Tests\\Fixtures\\ComplexHierarchy\\SubClassA')));
     $driver->expects($this->at(2))->method('loadMetadataForClass')->with($this->equalTo(new \ReflectionClass('Metadata\\Tests\\Fixtures\\ComplexHierarchy\\InterfaceB')));
     $driver->expects($this->at(1))->method('loadMetadataForClass')->with($this->equalTo(new \ReflectionClass('Metadata\\Tests\\Fixtures\\ComplexHierarchy\\BaseClass')));
     $driver->expects($this->at(0))->method('loadMetadataForClass')->with($this->equalTo(new \ReflectionClass('Metadata\\Tests\\Fixtures\\ComplexHierarchy\\InterfaceA')));
     $factory = new MetadataFactory($driver);
     $factory->setIncludeInterfaces(true);
     $factory->getMetadataForClass('Metadata\\Tests\\Fixtures\\ComplexHierarchy\\SubClassA');
 }
예제 #6
0
 /**
  * Builds and return a Manager instance.
  *
  * @return Manager
  */
 public function build()
 {
     $annotationReader = $this->annotationReader;
     if (null === $annotationReader) {
         $annotationReader = new AnnotationReader();
         if (null !== $this->cacheDir) {
             $this->createDir($this->cacheDir . '/annotations');
             $annotationReader = new FileCacheReader($annotationReader, $this->cacheDir . '/annotations', $this->debug);
         }
     }
     $metadataDriver = $this->driverFactory->createDriver($this->metadataDirs, $annotationReader);
     $metadataFactory = new MetadataFactory($metadataDriver);
     $metadataFactory->setIncludeInterfaces($this->includeInterfaceMetadata);
     if (null !== $this->cacheDir) {
         $this->createDir($this->cacheDir . '/metadata');
         $metadataFactory->setCache(new FileCache($this->cacheDir . '/metadata'));
     }
     $schemaRegistry = new SchemaRegistry($this->schemaDirs);
     // TODO registry caching
     return new Manager($metadataFactory, $schemaRegistry);
 }