diff --git a/config/module.config.php b/config/module.config.php index d816b24..5fffa84 100644 --- a/config/module.config.php +++ b/config/module.config.php @@ -37,7 +37,7 @@ 'driver' => array( 'odm_default' => array( - 'class' => 'Doctrine\ODM\MongoDB\Mapping\Driver\DriverChain', + 'class' => 'Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain', 'drivers' => array() ) ), diff --git a/src/DoctrineMongoODMModule/Module.php b/src/DoctrineMongoODMModule/Module.php index c7883c8..f29f26a 100644 --- a/src/DoctrineMongoODMModule/Module.php +++ b/src/DoctrineMongoODMModule/Module.php @@ -90,7 +90,7 @@ public function getServiceConfiguration() 'factories' => array( 'doctrine.connection.odm_default' => new ODMService\ConnectionFactory('odm_default'), 'doctrine.configuration.odm_default' => new ODMService\ConfigurationFactory('odm_default'), - 'doctrine.driver.odm_default' => new ODMService\DriverFactory('odm_default'), + 'doctrine.driver.odm_default' => new CommonService\DriverFactory('odm_default'), 'doctrine.documentmanager.odm_default' => new ODMService\DocumentManagerFactory('odm_default'), 'doctrine.eventmanager.odm_default' => new CommonService\EventManagerFactory('odm_default'), ) diff --git a/src/DoctrineMongoODMModule/Service/DriverFactory.php b/src/DoctrineMongoODMModule/Service/DriverFactory.php deleted file mode 100644 index d951dfa..0000000 --- a/src/DoctrineMongoODMModule/Service/DriverFactory.php +++ /dev/null @@ -1,117 +0,0 @@ -. - */ -namespace DoctrineMongoODMModule\Service; - -use InvalidArgumentException; -use Doctrine\Common\Annotations; -use DoctrineMongoODMModule\Options\Driver as DriverOptions; -use DoctrineModule\Service\AbstractFactory; -use Zend\ServiceManager\ServiceLocatorInterface; - -/** - * - * @license MIT - * @link http://www.doctrine-project.org/ - * @since 0.1.0 - * @author Tim Roediger - */ -class DriverFactory extends AbstractFactory -{ - - /** - * - * @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator - * @return object - */ - public function createService(ServiceLocatorInterface $serviceLocator) - { - return $this->createDriver($serviceLocator, $this->getOptions($serviceLocator, 'driver')); - } - - /** - * Get the class name of the options associated with this factory. - * - * @return string - */ - public function getOptionsClass() - { - return 'DoctrineMongoODMModule\Options\Driver'; - } - - /** - * @param ServiceLocatorInterface $serviceLocator - * @param Driver $options - * @return mixed - * @throws \InvalidArgumentException - */ - protected function createDriver(ServiceLocatorInterface $serviceLocator, DriverOptions $options) - { - $class = $options->getClass(); - - if (!$class) { - throw new InvalidArgumentException('Drivers must specify a class'); - } - - if (!class_exists($class)) { - throw new InvalidArgumentException(sprintf( - 'Driver with type "%s" could not be found', - $class - )); - } - - // Not all drivers (DriverChain) require paths. - $paths = $options->getPaths(); - - // Special options for AnnotationDrivers. - if (($class == 'Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver') || - (is_subclass_of($class, 'Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver'))) - { - $reader = new Annotations\AnnotationReader; - $reader = new Annotations\CachedReader( - new Annotations\IndexedReader($reader), - $serviceLocator->get($options->getCache()) - ); - $driver = new $class($reader, $paths); - } else { - $driver = new $class($paths); - } - - // File-drivers allow extensions. - if ($options->getExtension() && method_exists($driver, 'setFileExtension')) { - $driver->setFileExtension($options->getExtension()); - } - - // Extra post-create options for DriverChain. - if ($driver instanceof \Doctrine\ODM\MongoDB\Mapping\Driver\DriverChain && $options->getDrivers()) { - $drivers = $options->getDrivers(); - - if (!is_array($drivers)) { - $drivers = array($drivers); - } - - foreach($drivers as $namespace => $driverName) { - $options = $this->getOptions($serviceLocator, 'driver', $driverName); - - $driver->addDriver($this->createDriver($serviceLocator, $options), $namespace); - } - } - - return $driver; - } -} \ No newline at end of file