PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, January 10, 2022

[FIXED] Symfony : What is the meaning of auto_mapping and auto_generate_proxy_classes

 January 10, 2022     doctrine-orm, symfony     No comments   

Issue

The configuration uses :

doctrine:
dbal:
  driver:   "%database_driver%"
   ....
orm:
    auto_generate_proxy_classes: "%kernel.debug%"
    auto_mapping: true

What is the exact meaning of auto_mapping? It is used in tons of examples with true and false, and no precise description. When does occurs the proxy generation if it's not auto ? By doctrine command-line tools ?


Solution

auto_mapping is where doctrine will automatically load the mapping from your bundle Resources/config/doctrine directory.

Setting it to false will mean that you will need to load the mappings yourself. It can be handy if you have mappings for entities rather than mapped superclasses in a vendor bundle that you want to override.

You can do this either by way of stating the mappings in the doctrine config ...

doctrine:
    orm:
        entity_managers:
            default:
                mappings:
                    AcmeUnknownBundle:
                        mapping:              true
                        type:                 yml
                        dir:                  "Resources/config/doctrine"
                        alias:                ~
                        prefix:               Acme\UnknownBundle\Entity
                        is_bundle:            true

adding them in some sort of mappings pass ...

class AcmeUnknownBundle extends Bundle
{
    public function build(ContainerBuilder $container)
    {
        parent::build($container);
        // ...

        $modelDir = realpath(__DIR__.'/Resources/config/doctrine/model');
        $mappings = array(
            $modelDir => 'Acme\UnknownBundle\Model',
        );

        $ormCompilerClass = 'Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass';
        if (class_exists($ormCompilerClass)) {
            $container->addCompilerPass(
                DoctrineOrmMappingsPass::createYamlMappingDriver(
                    $mappings,
                    array('acme_unknown.model_manager_name'),
                    true
            ));
        }
    }
}


Answered By - qooplmao
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing