Doctrine\ODM\MongoDB\Configuration::newDefaultAnnotationDriver PHP Method

newDefaultAnnotationDriver() public method

Add a new default annotation driver with a correctly configured annotation reader.
public newDefaultAnnotationDriver ( array $paths = [] ) : AnnotationDriver
$paths array
return Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver
    public function newDefaultAnnotationDriver($paths = array())
    {
        $reader = new \Doctrine\Common\Annotations\AnnotationReader();
        $reader->setDefaultAnnotationNamespace('Doctrine\ODM\MongoDB\Mapping\\');
        
        return new \Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver($reader, (array) $paths);
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * @return DocumentManager
  */
 private function connect()
 {
     $config = new Configuration();
     $config->setProxyDir($this->app['cache']['doctrine'] . '/mongodb/proxy');
     $config->setProxyNamespace('Proxies');
     $config->setHydratorDir($this->app['cache']['doctrine'] . '/mongodb/hydrators');
     $config->setHydratorNamespace('Hydrators');
     $anno = [];
     foreach ($this->config['modules'] as $app) {
         $dir = $this->app['BASE_DIR'] . $this->app['Modules'] . $app . '/Document';
         if (file_exists($dir)) {
             $anno[] = $dir;
         }
     }
     $driverImpl = $config->newDefaultAnnotationDriver($anno);
     $config->setMetadataDriverImpl($driverImpl);
     $config->setDefaultDB($this->config['database']['name']);
     $config->setDefaultCommitOptions(array('safe' => true, 'fsync' => true));
     return DocumentManager::create(new Connection($this->config['database']['host']), $config);
 }
All Usage Examples Of Doctrine\ODM\MongoDB\Configuration::newDefaultAnnotationDriver