Symfony : auto_mapping 和 auto_generate_proxy_classes 是什么意思 [英] Symfony : What is the meaning of auto_mapping and auto_generate_proxy_classes
问题描述
配置使用:
doctrine:
dbal:
driver: "%database_driver%"
....
orm:
auto_generate_proxy_classes: "%kernel.debug%"
auto_mapping: true
auto_mapping
的确切含义是什么?被用在大量真假例子中,没有准确的描述.如果不是 auto ,代理生成什么时候发生?通过学说命令行工具?
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 ?
推荐答案
auto_mapping
是指从你的包Resources/config/doctrine
目录中自动加载映射的地方.
auto_mapping
is where doctrine will automatically load the mapping from your bundle Resources/config/doctrine
directory.
将其设置为 false 将意味着您需要自己加载映射.如果您有实体的映射而不是要覆盖的供应商包中的映射超类,这会很方便.
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: AcmeUnknownBundleEntity
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 => 'AcmeUnknownBundleModel',
);
$ormCompilerClass = 'DoctrineBundleDoctrineBundleDependencyInjectionCompilerDoctrineOrmMappingsPass';
if (class_exists($ormCompilerClass)) {
$container->addCompilerPass(
DoctrineOrmMappingsPass::createYamlMappingDriver(
$mappings,
array('acme_unknown.model_manager_name'),
true
));
}
}
}
这篇关于Symfony : auto_mapping 和 auto_generate_proxy_classes 是什么意思的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!