create() public static method

Factory method for the Annotation Driver
public static create ( array | string $paths = [] ) : AnnotationDriver
$paths array | string
return AnnotationDriver
Ejemplo n.º 1
0
 /**
  * Creates an instance of the Drest Manager using the passed configuration object
  * Can also pass in a Event Manager instance
  *
  * @param EntityManager $em
  * @param Configuration $config
  * @param Event\Manager $eventManager
  */
 private function __construct(EntityManager $em, Configuration $config, Event\Manager $eventManager)
 {
     $this->em = $em;
     $this->config = $config;
     $this->eventManager = $eventManager;
     $this->service = new Service($this->em, $this);
     // Router is internal and currently cannot be injected / extended
     $this->router = new Router();
     $this->metadataFactory = new MetadataFactory(Mapping\Driver\AnnotationDriver::create(new AnnotationReader(), $config->getPathsToConfigFiles()));
     if ($cache = $config->getMetadataCacheImpl()) {
         $this->metadataFactory->setCache($cache);
     }
 }
Ejemplo n.º 2
0
 public function testClassMetadataElementName()
 {
     $metadataFactory = new MetadataFactory(\Drest\Mapping\Driver\AnnotationDriver::create(array(__DIR__ . '/../Entities/Typical')));
     $className = 'DrestTests\\Entities\\Typical\\User';
     $cmd = $metadataFactory->getMetadataForClass($className);
     $this->assertEquals('user', $cmd->getElementName());
 }
Ejemplo n.º 3
0
 public function testRemovingExtension()
 {
     $annotationDriver = \Drest\Mapping\Driver\AnnotationDriver::create(array(__DIR__ . '/../Entities/Typical'));
     $annotationDriver->removeExtensions();
     $metadataFactory = new MetadataFactory($annotationDriver);
     $this->assertCount(0, $metadataFactory->getAllClassNames());
     $annotationDriver->addExtension('php');
     $this->assertGreaterThan(0, $metadataFactory->getAllClassNames());
 }