交响乐团 : What is the meaning of auto_mapping and auto_generate_proxy_classes

标签 symfony doctrine-orm

配置使用:

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

auto_mapping 的确切含义是什么?它被用在大量的例子中,有真有假,没有精确的描述。 如果不是自动生成代理,什么时候会发生?通过学说命令行工具?

最佳答案

auto_mapping 是 Doctrine 会自动从您的包 Resources/config/doctrine 目录加载映射的位置。

将其设置为 false 将意味着您需要自己加载映射。如果您有实体的映射而不是要覆盖的供应商包中的映射父类(super class),那么它会很方便。

您可以通过在学说配置中声明映射来完成此操作...

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

将它们添加到某种 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
            ));
        }
    }
}

关于交响乐团 : What is the meaning of auto_mapping and auto_generate_proxy_classes,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26974519/

相关文章:

symfony - 从一对多关系中删除项目

symfony - Doctrine2类表继承和级联删除

symfony - Doctrine :多对多在事件监听器内删除关联对象

symfony - 更改现有表名

php - 我如何在 doctrine 2 实体的存储库中使用复杂的标准?

symfony - 在 Laravel 4 中使用 CssSelector

doctrine - Symfony2 Doctrine

symfony2 : trying to load fixtures using hautelook/alicebundle

validation - 如何定义至少需要 2 个字段之一的 Symfony2 表单(无实体)?

symfony - Easyadmin manyToMany 关系不在基础中保存数据