From 804e159e974211ec5f08003b8568ed2cc08db5d6 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Mon, 8 Apr 2013 14:08:00 +0200 Subject: [PATCH 1/8] add compiler pass for bundles to register mappings --- .../CompilerPass/RegisterMappingsPass.php | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 DependencyInjection/CompilerPass/RegisterMappingsPass.php diff --git a/DependencyInjection/CompilerPass/RegisterMappingsPass.php b/DependencyInjection/CompilerPass/RegisterMappingsPass.php new file mode 100644 index 000000000..862a25d60 --- /dev/null +++ b/DependencyInjection/CompilerPass/RegisterMappingsPass.php @@ -0,0 +1,64 @@ + + * (c) Doctrine Project, Benjamin Eberlei + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Doctrine\Bundle\DoctrineBundle\DependencyInjection\CompilerPass; + +use Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass\RegisterMappingsPass as BaseMappingPass; +use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; + +/** + * Class for Symfony bundles to configure mappings for model classes not in the + * automapped folder. + * + * TODO: if we need support for the annotation driver too, we probably need an + * extra compiler pass overwriting buildDriver, as its quite different + * + * @author David Buchmann + */ +class RegisterMappingsPass extends BaseMappingPass +{ + /** + * @param array $mappings hashmap of absolute directory paths to namespaces + * @param string $type type of mapping, allowed are xml, yml, php + * @param bool $enabledParameter if specified, the compiler pass only + * executes if this parameter exists in the service container. + */ + public function __construct(array $mappings, $type, $enabledParameter = false) + { + switch($type) { + case 'xml': + $extension = '.orm.xml'; + $driverClass = 'Doctrine\ORM\Mapping\Driver\XmlDriver'; + break; + case 'yml': + $extension = '.yml.xml'; + $driverClass = 'Doctrine\ORM\Mapping\Driver\YamlDriver'; + break; + case 'php': + $extension = '.php'; + $driverClass = 'Doctrine\ORM\Mapping\Driver\PHPDriver'; + break; + default: + throw new InvalidArgumentException($type); + } + + parent::__construct( + $mappings, + $extension, + 'doctrine.entity_managers', + $driverClass, + 'doctrine.orm.%s_metadata_driver', + $enabledParameter + ); + + } +} From 9a9191fa0980dbde0df63c1b4feee3974c3858c5 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Mon, 15 Apr 2013 20:33:30 +0200 Subject: [PATCH 2/8] refactor instantiation to use factory methods --- .../Compiler/DoctrineOrmMappingsPass.php | 121 ++++++++++++++++++ .../CompilerPass/RegisterMappingsPass.php | 64 --------- 2 files changed, 121 insertions(+), 64 deletions(-) create mode 100644 DependencyInjection/Compiler/DoctrineOrmMappingsPass.php delete mode 100644 DependencyInjection/CompilerPass/RegisterMappingsPass.php diff --git a/DependencyInjection/Compiler/DoctrineOrmMappingsPass.php b/DependencyInjection/Compiler/DoctrineOrmMappingsPass.php new file mode 100644 index 000000000..cc97f0c67 --- /dev/null +++ b/DependencyInjection/Compiler/DoctrineOrmMappingsPass.php @@ -0,0 +1,121 @@ + + * (c) Doctrine Project, Benjamin Eberlei + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler; + +use Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass\RegisterMappingsPass as BaseMappingPass; +use Symfony\Component\DependencyInjection\Definition; +use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; +use Symfony\Component\DependencyInjection\Reference; + +/** + * Class for Symfony bundles to configure mappings for model classes not in the + * automapped folder. + * + * @author David Buchmann + */ +class DoctrineOrmMappingsPass extends BaseMappingPass +{ + /** + * You should not directly instantiate this class but use one of the + * factory methods. + * + * @param array $mappings hashmap of absolute directory paths to namespaces + * @param string $type type of mapping, allowed are xml, yml, php + * @param bool $enabledParameter if specified, the compiler pass only + * executes if this parameter exists in the service container. + */ + public function __construct($driver, $namespaces, $enabledParameter = false) + { + parent::__construct( + $driver, + $namespaces, + 'doctrine.entity_managers', + 'doctrine.orm.%s_metadata_driver', + $enabledParameter + ); + + } + + /** + * @param array $mappings Hashmap of directory path to namespace + * @param string $enabledParameter Service container parameter that must be + * present to enable the mapping. Set to false to not do any check, optional. + */ + public static function createXmlMappingDriver(array $mappings, $enabledParameter = false) + { + $arguments = array($mappings, '.orm.xml'); + $locator = new Definition('Doctrine\Common\Persistence\Mapping\Driver\SymfonyFileLocator', $arguments); + $driver = new Definition('Doctrine\ORM\Mapping\Driver\XmlDriver', array($locator)); + + return new DoctrineOrmMappingsPass($driver, $mappings, $enabledParameter); + } + + /** + * @param array $mappings Hashmap of directory path to namespace + * @param string $enabledParameter Service container parameter that must be + * present to enable the mapping. Set to false to not do any check, optional. + */ + public static function createYmlMappingDriver(array $mappings, $enabledParameter = false) + { + $arguments = array($mappings, '.orm.yml'); + $locator = new Definition('Doctrine\Common\Persistence\Mapping\Driver\SymfonyFileLocator', $arguments); + $driver = new Definition('Doctrine\ORM\Mapping\Driver\YamlDriver', array($locator)); + + return new DoctrineOrmMappingsPass($driver, $mappings, $enabledParameter); + } + + /** + * @param array $mappings Hashmap of directory path to namespace + * @param string $enabledParameter Service container parameter that must be + * present to enable the mapping. Set to false to not do any check, optional. + */ + public static function createPhpMappingDriver(array $mappings, $enabledParameter = false) + { + $arguments = array($mappings, '.php'); + $locator = new Definition('Doctrine\Common\Persistence\Mapping\Driver\SymfonyFileLocator', $arguments); + $driver = new Definition('Doctrine\ORM\Mapping\Driver\PHPDriver', array($locator)); + + return new DoctrineOrmMappingsPass($driver, $mappings, $enabledParameter); + } + + /** + * @param array $namespaces List of namespaces that are handled with annotation mapping + * @param array $directories List of directories to look for annotation mapping files + * @param string $enabledParameter Service container parameter that must be + * present to enable the mapping. Set to false to not do any check, optional. + */ + public static function createAnnotationMappingDriver(array $namespaces, array $directories, $enabledParameter = false) + { + $arguments = array(new Reference('doctrine.orm.metadata.annotation_reader'), $directories); + $locator = new Definition('Doctrine\Common\Persistence\Mapping\Driver\SymfonyFileLocator', $arguments); + $driver = new Definition('Doctrine\ORM\Mapping\Driver\AnnotationDriver', array($locator)); + + return new DoctrineOrmMappingsPass($driver, $namespaces, $enabledParameter); + } + + /** + * @param array $namespaces List of namespaces that are handled with static php mapping + * @param array $directories List of directories to look for static php mapping files + * @param string $enabledParameter Service container parameter that must be + * present to enable the mapping. Set to false to not do any check, optional. + */ + public static function createStaticPhpMappingDriver(array $namespaces, array $directories, $enabledParameter = false) + { + $arguments = array($directories); + $locator = new Definition('Doctrine\Common\Persistence\Mapping\Driver\SymfonyFileLocator', $arguments); + $driver = new Definition('Doctrine\ORM\Mapping\Driver\StaticPHPDriver', array($locator)); + + return new DoctrineOrmMappingsPass($driver, $namespaces, $enabledParameter); + } + +} diff --git a/DependencyInjection/CompilerPass/RegisterMappingsPass.php b/DependencyInjection/CompilerPass/RegisterMappingsPass.php deleted file mode 100644 index 862a25d60..000000000 --- a/DependencyInjection/CompilerPass/RegisterMappingsPass.php +++ /dev/null @@ -1,64 +0,0 @@ - - * (c) Doctrine Project, Benjamin Eberlei - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Doctrine\Bundle\DoctrineBundle\DependencyInjection\CompilerPass; - -use Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass\RegisterMappingsPass as BaseMappingPass; -use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; - -/** - * Class for Symfony bundles to configure mappings for model classes not in the - * automapped folder. - * - * TODO: if we need support for the annotation driver too, we probably need an - * extra compiler pass overwriting buildDriver, as its quite different - * - * @author David Buchmann - */ -class RegisterMappingsPass extends BaseMappingPass -{ - /** - * @param array $mappings hashmap of absolute directory paths to namespaces - * @param string $type type of mapping, allowed are xml, yml, php - * @param bool $enabledParameter if specified, the compiler pass only - * executes if this parameter exists in the service container. - */ - public function __construct(array $mappings, $type, $enabledParameter = false) - { - switch($type) { - case 'xml': - $extension = '.orm.xml'; - $driverClass = 'Doctrine\ORM\Mapping\Driver\XmlDriver'; - break; - case 'yml': - $extension = '.yml.xml'; - $driverClass = 'Doctrine\ORM\Mapping\Driver\YamlDriver'; - break; - case 'php': - $extension = '.php'; - $driverClass = 'Doctrine\ORM\Mapping\Driver\PHPDriver'; - break; - default: - throw new InvalidArgumentException($type); - } - - parent::__construct( - $mappings, - $extension, - 'doctrine.entity_managers', - $driverClass, - 'doctrine.orm.%s_metadata_driver', - $enabledParameter - ); - - } -} From 61561fce13ec42fef05c1b20df8a268ca2bfdcf7 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Mon, 15 Apr 2013 21:05:20 +0200 Subject: [PATCH 3/8] fix typo and cleanup docblock --- DependencyInjection/Compiler/DoctrineOrmMappingsPass.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/DependencyInjection/Compiler/DoctrineOrmMappingsPass.php b/DependencyInjection/Compiler/DoctrineOrmMappingsPass.php index cc97f0c67..94596baa1 100644 --- a/DependencyInjection/Compiler/DoctrineOrmMappingsPass.php +++ b/DependencyInjection/Compiler/DoctrineOrmMappingsPass.php @@ -29,9 +29,9 @@ class DoctrineOrmMappingsPass extends BaseMappingPass * You should not directly instantiate this class but use one of the * factory methods. * - * @param array $mappings hashmap of absolute directory paths to namespaces - * @param string $type type of mapping, allowed are xml, yml, php - * @param bool $enabledParameter if specified, the compiler pass only + * @param Definition|Reference $driver the driver to use + * @param array $namespaces list of namespaces this driver should handle + * @param bool $enabledParameter if specified, the compiler pass only * executes if this parameter exists in the service container. */ public function __construct($driver, $namespaces, $enabledParameter = false) @@ -65,7 +65,7 @@ public static function createXmlMappingDriver(array $mappings, $enabledParameter * @param string $enabledParameter Service container parameter that must be * present to enable the mapping. Set to false to not do any check, optional. */ - public static function createYmlMappingDriver(array $mappings, $enabledParameter = false) + public static function createYamlMappingDriver(array $mappings, $enabledParameter = false) { $arguments = array($mappings, '.orm.yml'); $locator = new Definition('Doctrine\Common\Persistence\Mapping\Driver\SymfonyFileLocator', $arguments); From fb026c25fb14fc7f4320f7f1c2471083e6b533ab Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Fri, 19 Apr 2013 14:57:34 +0200 Subject: [PATCH 4/8] fix issues on compiler pass --- .../Compiler/DoctrineOrmMappingsPass.php | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/DependencyInjection/Compiler/DoctrineOrmMappingsPass.php b/DependencyInjection/Compiler/DoctrineOrmMappingsPass.php index 94596baa1..f600653a6 100644 --- a/DependencyInjection/Compiler/DoctrineOrmMappingsPass.php +++ b/DependencyInjection/Compiler/DoctrineOrmMappingsPass.php @@ -12,7 +12,7 @@ namespace Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler; -use Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass\RegisterMappingsPass as BaseMappingPass; +use Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass\RegisterMappingsPass; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\DependencyInjection\Reference; @@ -23,7 +23,7 @@ * * @author David Buchmann */ -class DoctrineOrmMappingsPass extends BaseMappingPass +class DoctrineOrmMappingsPass extends RegisterMappingsPass { /** * You should not directly instantiate this class but use one of the @@ -90,15 +90,14 @@ public static function createPhpMappingDriver(array $mappings, $enabledParameter /** * @param array $namespaces List of namespaces that are handled with annotation mapping - * @param array $directories List of directories to look for annotation mapping files + * @param array $directories List of directories to look for annotated classes * @param string $enabledParameter Service container parameter that must be * present to enable the mapping. Set to false to not do any check, optional. */ public static function createAnnotationMappingDriver(array $namespaces, array $directories, $enabledParameter = false) { - $arguments = array(new Reference('doctrine.orm.metadata.annotation_reader'), $directories); - $locator = new Definition('Doctrine\Common\Persistence\Mapping\Driver\SymfonyFileLocator', $arguments); - $driver = new Definition('Doctrine\ORM\Mapping\Driver\AnnotationDriver', array($locator)); + $reader = new Reference('doctrine.orm.metadata.annotation_reader'); + $driver = new Definition('Doctrine\ORM\Mapping\Driver\AnnotationDriver', array($reader, $directories)); return new DoctrineOrmMappingsPass($driver, $namespaces, $enabledParameter); } @@ -111,9 +110,7 @@ public static function createAnnotationMappingDriver(array $namespaces, array $d */ public static function createStaticPhpMappingDriver(array $namespaces, array $directories, $enabledParameter = false) { - $arguments = array($directories); - $locator = new Definition('Doctrine\Common\Persistence\Mapping\Driver\SymfonyFileLocator', $arguments); - $driver = new Definition('Doctrine\ORM\Mapping\Driver\StaticPHPDriver', array($locator)); + $driver = new Definition('Doctrine\ORM\Mapping\Driver\StaticPHPDriver', array($directories)); return new DoctrineOrmMappingsPass($driver, $namespaces, $enabledParameter); } From df8ce8c8a53ff3d0c0036fa391ae288708a7874b Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Sun, 21 Apr 2013 10:49:58 +0200 Subject: [PATCH 5/8] adjust to https://github.com/symfony/symfony/pull/7755 --- .../Compiler/DoctrineOrmMappingsPass.php | 92 ++++++++++++------- 1 file changed, 59 insertions(+), 33 deletions(-) diff --git a/DependencyInjection/Compiler/DoctrineOrmMappingsPass.php b/DependencyInjection/Compiler/DoctrineOrmMappingsPass.php index f600653a6..1ddfe63d5 100644 --- a/DependencyInjection/Compiler/DoctrineOrmMappingsPass.php +++ b/DependencyInjection/Compiler/DoctrineOrmMappingsPass.php @@ -29,17 +29,19 @@ class DoctrineOrmMappingsPass extends RegisterMappingsPass * You should not directly instantiate this class but use one of the * factory methods. * - * @param Definition|Reference $driver the driver to use - * @param array $namespaces list of namespaces this driver should handle - * @param bool $enabledParameter if specified, the compiler pass only + * @param Definition|Reference $driver the driver to use + * @param array $namespaces list of namespaces this driver should handle + * @param string[] $managerParameters list of parameters that could tell the manager name to use + * @param bool $enabledParameter if specified, the compiler pass only * executes if this parameter exists in the service container. */ - public function __construct($driver, $namespaces, $enabledParameter = false) + public function __construct($driver, $namespaces, array $managerParameters, $enabledParameter = false) { + $managerParameters[] = 'doctrine.default_entity_manager'; parent::__construct( $driver, $namespaces, - 'doctrine.entity_managers', + $managerParameters, 'doctrine.orm.%s_metadata_driver', $enabledParameter ); @@ -47,72 +49,96 @@ public function __construct($driver, $namespaces, $enabledParameter = false) } /** - * @param array $mappings Hashmap of directory path to namespace - * @param string $enabledParameter Service container parameter that must be - * present to enable the mapping. Set to false to not do any check, optional. + * @param array $mappings Hashmap of directory path to namespace + * @param string[] $managerParameters List of parameters that could which object manager name + * your bundle uses. This compiler pass will automatically + * append the parameter name for the default entity manager + * to this list. + * @param string $enabledParameter Service container parameter that must be present to + * enable the mapping. Set to false to not do any check, + * optional. */ - public static function createXmlMappingDriver(array $mappings, $enabledParameter = false) + public static function createXmlMappingDriver(array $mappings, array $managerParameters = array(), $enabledParameter = false) { $arguments = array($mappings, '.orm.xml'); $locator = new Definition('Doctrine\Common\Persistence\Mapping\Driver\SymfonyFileLocator', $arguments); $driver = new Definition('Doctrine\ORM\Mapping\Driver\XmlDriver', array($locator)); - return new DoctrineOrmMappingsPass($driver, $mappings, $enabledParameter); + return new DoctrineOrmMappingsPass($driver, $mappings, $managerParameters, $enabledParameter); } /** - * @param array $mappings Hashmap of directory path to namespace - * @param string $enabledParameter Service container parameter that must be - * present to enable the mapping. Set to false to not do any check, optional. + * @param array $mappings Hashmap of directory path to namespace + * @param string[] $managerParameters List of parameters that could which object manager name + * your bundle uses. This compiler pass will automatically + * append the parameter name for the default entity manager + * to this list. + * @param string $enabledParameter Service container parameter that must be present to + * enable the mapping. Set to false to not do any check, + * optional. */ - public static function createYamlMappingDriver(array $mappings, $enabledParameter = false) + public static function createYamlMappingDriver(array $mappings, array $managerParameters = array(), $enabledParameter = false) { $arguments = array($mappings, '.orm.yml'); $locator = new Definition('Doctrine\Common\Persistence\Mapping\Driver\SymfonyFileLocator', $arguments); $driver = new Definition('Doctrine\ORM\Mapping\Driver\YamlDriver', array($locator)); - return new DoctrineOrmMappingsPass($driver, $mappings, $enabledParameter); + return new DoctrineOrmMappingsPass($driver, $mappings, $managerParameters, $enabledParameter); } /** - * @param array $mappings Hashmap of directory path to namespace - * @param string $enabledParameter Service container parameter that must be - * present to enable the mapping. Set to false to not do any check, optional. + * @param array $mappings Hashmap of directory path to namespace + * @param string[] $managerParameters List of parameters that could which object manager name + * your bundle uses. This compiler pass will automatically + * append the parameter name for the default entity manager + * to this list. + * @param string $enabledParameter Service container parameter that must be present to + * enable the mapping. Set to false to not do any check, + * optional. */ - public static function createPhpMappingDriver(array $mappings, $enabledParameter = false) + public static function createPhpMappingDriver(array $mappings, array $managerParameters = array(), $enabledParameter = false) { $arguments = array($mappings, '.php'); $locator = new Definition('Doctrine\Common\Persistence\Mapping\Driver\SymfonyFileLocator', $arguments); $driver = new Definition('Doctrine\ORM\Mapping\Driver\PHPDriver', array($locator)); - return new DoctrineOrmMappingsPass($driver, $mappings, $enabledParameter); + return new DoctrineOrmMappingsPass($driver, $mappings, $managerParameters, $enabledParameter); } /** - * @param array $namespaces List of namespaces that are handled with annotation mapping - * @param array $directories List of directories to look for annotated classes - * @param string $enabledParameter Service container parameter that must be - * present to enable the mapping. Set to false to not do any check, optional. + * @param array $namespaces List of namespaces that are handled with annotation mapping + * @param array $directories List of directories to look for annotated classes + * @param string[] $managerParameters List of parameters that could which object manager name + * your bundle uses. This compiler pass will automatically + * append the parameter name for the default entity manager + * to this list. + * @param string $enabledParameter Service container parameter that must be present to + * enable the mapping. Set to false to not do any check, + * optional. */ - public static function createAnnotationMappingDriver(array $namespaces, array $directories, $enabledParameter = false) + public static function createAnnotationMappingDriver(array $namespaces, array $directories, array $managerParameters = array(), $enabledParameter = false) { $reader = new Reference('doctrine.orm.metadata.annotation_reader'); $driver = new Definition('Doctrine\ORM\Mapping\Driver\AnnotationDriver', array($reader, $directories)); - return new DoctrineOrmMappingsPass($driver, $namespaces, $enabledParameter); + return new DoctrineOrmMappingsPass($driver, $namespaces, $managerParameters, $enabledParameter); } /** - * @param array $namespaces List of namespaces that are handled with static php mapping - * @param array $directories List of directories to look for static php mapping files - * @param string $enabledParameter Service container parameter that must be - * present to enable the mapping. Set to false to not do any check, optional. + * @param array $namespaces List of namespaces that are handled with static php mapping + * @param array $directories List of directories to look for static php mapping files + * @param string[] $managerParameters List of parameters that could which object manager name + * your bundle uses. This compiler pass will automatically + * append the parameter name for the default entity manager + * to this list. + * @param string $enabledParameter Service container parameter that must be present to + * enable the mapping. Set to false to not do any check, + * optional. */ - public static function createStaticPhpMappingDriver(array $namespaces, array $directories, $enabledParameter = false) + public static function createStaticPhpMappingDriver(array $namespaces, array $directories, array $managerParameters = array(), $enabledParameter = false) { $driver = new Definition('Doctrine\ORM\Mapping\Driver\StaticPHPDriver', array($directories)); - return new DoctrineOrmMappingsPass($driver, $namespaces, $enabledParameter); + return new DoctrineOrmMappingsPass($driver, $namespaces, $managerParameters, $enabledParameter); } - } From cf4e0c26d007e0e171e059fdc3257f3329f1391d Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Sun, 21 Apr 2013 11:00:50 +0200 Subject: [PATCH 6/8] use drivers from common, not deprecated orm ones --- DependencyInjection/Compiler/DoctrineOrmMappingsPass.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DependencyInjection/Compiler/DoctrineOrmMappingsPass.php b/DependencyInjection/Compiler/DoctrineOrmMappingsPass.php index 1ddfe63d5..cf7534502 100644 --- a/DependencyInjection/Compiler/DoctrineOrmMappingsPass.php +++ b/DependencyInjection/Compiler/DoctrineOrmMappingsPass.php @@ -100,7 +100,7 @@ public static function createPhpMappingDriver(array $mappings, array $managerPar { $arguments = array($mappings, '.php'); $locator = new Definition('Doctrine\Common\Persistence\Mapping\Driver\SymfonyFileLocator', $arguments); - $driver = new Definition('Doctrine\ORM\Mapping\Driver\PHPDriver', array($locator)); + $driver = new Definition('Doctrine\Common\Persistence\Mapping\Driver\PHPDriver', array($locator)); return new DoctrineOrmMappingsPass($driver, $mappings, $managerParameters, $enabledParameter); } @@ -137,7 +137,7 @@ public static function createAnnotationMappingDriver(array $namespaces, array $d */ public static function createStaticPhpMappingDriver(array $namespaces, array $directories, array $managerParameters = array(), $enabledParameter = false) { - $driver = new Definition('Doctrine\ORM\Mapping\Driver\StaticPHPDriver', array($directories)); + $driver = new Definition('Doctrine\Common\Persistence\Mapping\Driver\StaticPHPDriver', array($directories)); return new DoctrineOrmMappingsPass($driver, $namespaces, $managerParameters, $enabledParameter); } From 8748d37960d95cbeff464a7f55e71606177d8fe7 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Wed, 24 Apr 2013 13:45:26 +0200 Subject: [PATCH 7/8] improve doc on managerParameters --- .../Compiler/DoctrineOrmMappingsPass.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/DependencyInjection/Compiler/DoctrineOrmMappingsPass.php b/DependencyInjection/Compiler/DoctrineOrmMappingsPass.php index cf7534502..4878e5bc5 100644 --- a/DependencyInjection/Compiler/DoctrineOrmMappingsPass.php +++ b/DependencyInjection/Compiler/DoctrineOrmMappingsPass.php @@ -30,10 +30,12 @@ class DoctrineOrmMappingsPass extends RegisterMappingsPass * factory methods. * * @param Definition|Reference $driver the driver to use - * @param array $namespaces list of namespaces this driver should handle - * @param string[] $managerParameters list of parameters that could tell the manager name to use - * @param bool $enabledParameter if specified, the compiler pass only - * executes if this parameter exists in the service container. + * @param array $namespaces list of namespaces this driver should handle. + * @param string[] $managerParameters ordered list of container parameters that may + * provide the name of the manager to register the mappings for. The first non-empty name + * is used, the others skipped. + * @param bool $enabledParameter if specified, the compiler pass only executes + * if this parameter exists in the service container. */ public function __construct($driver, $namespaces, array $managerParameters, $enabledParameter = false) { From 06800df011467b767f2fa46e9ae5242a691bc15c Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Wed, 24 Apr 2013 13:49:12 +0200 Subject: [PATCH 8/8] ws fixes --- .../Compiler/DoctrineOrmMappingsPass.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/DependencyInjection/Compiler/DoctrineOrmMappingsPass.php b/DependencyInjection/Compiler/DoctrineOrmMappingsPass.php index 4878e5bc5..0fafd0ab5 100644 --- a/DependencyInjection/Compiler/DoctrineOrmMappingsPass.php +++ b/DependencyInjection/Compiler/DoctrineOrmMappingsPass.php @@ -89,12 +89,12 @@ public static function createYamlMappingDriver(array $mappings, array $managerPa } /** - * @param array $mappings Hashmap of directory path to namespace + * @param array $mappings Hashmap of directory path to namespace * @param string[] $managerParameters List of parameters that could which object manager name * your bundle uses. This compiler pass will automatically * append the parameter name for the default entity manager * to this list. - * @param string $enabledParameter Service container parameter that must be present to + * @param string $enabledParameter Service container parameter that must be present to * enable the mapping. Set to false to not do any check, * optional. */ @@ -108,13 +108,13 @@ public static function createPhpMappingDriver(array $mappings, array $managerPar } /** - * @param array $namespaces List of namespaces that are handled with annotation mapping - * @param array $directories List of directories to look for annotated classes + * @param array $namespaces List of namespaces that are handled with annotation mapping + * @param array $directories List of directories to look for annotated classes * @param string[] $managerParameters List of parameters that could which object manager name * your bundle uses. This compiler pass will automatically * append the parameter name for the default entity manager * to this list. - * @param string $enabledParameter Service container parameter that must be present to + * @param string $enabledParameter Service container parameter that must be present to * enable the mapping. Set to false to not do any check, * optional. */ @@ -127,13 +127,13 @@ public static function createAnnotationMappingDriver(array $namespaces, array $d } /** - * @param array $namespaces List of namespaces that are handled with static php mapping - * @param array $directories List of directories to look for static php mapping files + * @param array $namespaces List of namespaces that are handled with static php mapping + * @param array $directories List of directories to look for static php mapping files * @param string[] $managerParameters List of parameters that could which object manager name * your bundle uses. This compiler pass will automatically * append the parameter name for the default entity manager * to this list. - * @param string $enabledParameter Service container parameter that must be present to + * @param string $enabledParameter Service container parameter that must be present to * enable the mapping. Set to false to not do any check, * optional. */