Skip to content

Commit

Permalink
[DoctrineBundle] fixed auto-mapping
Browse files Browse the repository at this point in the history
When auto_mapping is true, you can avoid a bundle to be
automatically mapped by setting the value to false:

    auto_mapping: true
    mappings:
        BlogBundle: false

With the above configuration, all bundles will be
auto-mapped, but the BlogBundle won't be.

Bundles that are defined in mappings won't be
managed by the auto-mapping feature:

    auto_mapping: true
    mappings:
        BlogBundle: xml
  • Loading branch information
fabpot committed Apr 30, 2011
1 parent ad3fd30 commit 8b85458
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Expand Up @@ -42,7 +42,7 @@ abstract class AbstractDoctrineExtension extends Extension
*/
protected function loadMappingInformation(array $objectManager, ContainerBuilder $container)
{
if (!$objectManager['mappings'] && $objectManager['auto_mapping']) {
if ($objectManager['auto_mapping']) {
// automatically register bundle mappings
foreach (array_keys($container->getParameter('kernel.bundles')) as $bundle) {
if (!isset($objectManager['mappings'][$bundle])) {
Expand All @@ -52,7 +52,7 @@ protected function loadMappingInformation(array $objectManager, ContainerBuilder
}

foreach ($objectManager['mappings'] as $mappingName => $mappingConfig) {
if (false === $mappingConfig) {
if (null !== $mappingConfig && false === $mappingConfig['mapping']) {

This comment has been minimized.

Copy link
@stloyd

stloyd May 1, 2011

Contributor

Fix for those notices at PR: #721

continue;
}

Expand Down
Expand Up @@ -224,11 +224,13 @@ private function getOrmEntityManagersNode()
->prototype('array')
->beforeNormalization()
->ifString()
->then(function($v) { return array ('type' => $v); })
->then(function($v) { return array('type' => $v); })
->end()
->treatNullLike(array ())
->treatNullLike(array())
->treatFalseLike(array('mapping' => false))
->performNoDeepMerging()
->children()
->scalarNode('mapping')->defaultValue(true)->end()
->scalarNode('type')->end()
->scalarNode('dir')->end()
->scalarNode('alias')->end()
Expand Down Expand Up @@ -272,7 +274,7 @@ private function getOrmCacheDriverNode($name)
->addDefaultsIfNotSet()
->beforeNormalization()
->ifString()
->then(function($v) { return array ('type' => $v); })
->then(function($v) { return array('type' => $v); })
->end()
->children()
->scalarNode('type')->defaultValue('array')->isRequired()->end()
Expand Down

0 comments on commit 8b85458

Please sign in to comment.