1

在适应 Symfony 2.7 中新的推荐结构后,我无法通过$em->getRepository('Bundle:Entity').

这是我的目录结构:

MyBundle
    - Component
        - Catalog
            - Model
                Product.php

我的映射定义在config.yml

mappings:
    mybundle:
        type:      annotation
        dir:       %kernel.root_dir%/../src/mybundle/Component/Product/Model
        prefix:    MyBundle\Component\Product\Model
        alias:     ??? # I tried different things

我应该写什么$em->getRepository('MyBundle:Product')而不是MyBundle:Product成功访问实体?

如果可能的话,我想使用默认的 Symfony 别名,所以我不需要为每个实体指定别名config.yml

4

1 回答 1

1

实际上我不需要generate:bundle,因为它不是一个真正的包,而是一个名称空间和文件的逻辑组织。

解决方案是在以下位置指定完整的命名空间getRespository()

$em->getRepository('MyBundle\\Component\\Product\\Model\\CFGProduct)

谢谢

于 2015-07-01T09:43:51.410 回答