Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver::create PHP Method

create() public static method

Factory method for the Annotation Driver
public static create ( array | string $paths = [], Doctrine\Common\Annotations\Reader $reader = null ) : AnnotationDriver
$paths array | string
$reader Doctrine\Common\Annotations\Reader
return AnnotationDriver
    public static function create($paths = array(), Reader $reader = null)
    {
        if ($reader === null) {
            $reader = new AnnotationReader();
        }
        return new self($reader, $paths);
    }

Usage Example

Beispiel #1
0
 /**
  * Connect to MongoDb
  * @return DocumentManager
  */
 public function _initDb()
 {
     $container = $this;
     $this['documentManager'] = $this->share(function () use($container) {
         $dbConfigs = $container['configs']['database'];
         try {
             if (empty($dbConfigs['user'])) {
                 $connection_url = "mongodb://{$dbConfigs['host']}:{$dbConfigs['port']}/{$dbConfigs['name']}";
             } else {
                 $connection_url = "mongodb://{$dbConfigs['user']}:{$dbConfigs['passwd']}@{$dbConfigs['host']}:{$dbConfigs['port']}/{$dbConfigs['name']}";
             }
             AnnotationDriver::registerAnnotationClasses();
             $config = new Configuration();
             $config->setProxyDir(BIN_PATH . '/src/Blueridge/Documents/Proxies');
             $config->setProxyNamespace('Proxies');
             $config->setHydratorDir(BIN_PATH . '/src/Blueridge/Documents/Hydrators');
             $config->setHydratorNamespace('Hydrators');
             $config->setMetadataDriverImpl(AnnotationDriver::create(BIN_PATH . '/src/Blueridge/Documents'));
             $config->setDefaultDB($dbConfigs['name']);
             return DocumentManager::create(new Connection($connection_url), $config);
         } catch (Exception $e) {
             error_log($e->getMessage());
         }
     });
 }
All Usage Examples Of Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver::create