Php Symfony2/条令可以';找不到自定义存储库类的映射文件

Php Symfony2/条令可以';找不到自定义存储库类的映射文件,php,symfony,doctrine-orm,annotations,metadata,Php,Symfony,Doctrine Orm,Annotations,Metadata,我喜欢教义,但我在映射/注释方面有一些问题。一开始我使用映射文件。然后我将其转换为注释。现在,我想创建自定义存储库类,所以我在这里读到: 不幸的是,现在我有一个错误: No mapping file found named '\src\Vendor\ProductBundle\Resources\config\doctrine/SynchronizationSettingRepository.orm.yml' for class 'Vendor\ProductBundle\Entity\Sync

我喜欢教义,但我在映射/注释方面有一些问题。一开始我使用映射文件。然后我将其转换为注释。现在,我想创建自定义存储库类,所以我在这里读到:

不幸的是,现在我有一个错误:

No mapping file found named '\src\Vendor\ProductBundle\Resources\config\doctrine/SynchronizationSettingRepository.orm.yml' for class 'Vendor\ProductBundle\Entity\SynchronizationSettingRepository'. 
当然,我没有这个文件,因为我不再使用映射。 我补充说:

  * @ORM\Entity(repositoryClass="Vendor\ProductBundle\Entity\SynchronizationSettingRepository") 
创建和重新生成实体的父对象。我已经通过命令php-app/console原则重新生成了实体:generate:entities-VendorProductBundle,但仍然一无所获。数据缓存的规则和规则是清晰的

下面是一个YML,我想从中再次生成自定义存储库:

Vendor\ProductBundle\Entity\SynchronizationSetting:
    type: entity
    table: synchronization_setting
    repositoryClass: Vendor\SynchronizationSetting\Entity\SynchronizationSettingRepository
    indexes:
        id_product:
            columns:
                - id_product
    id:
        id:
            type: integer
            nullable: false
            unsigned: true
            comment: ''
            id: true
            generator:
                strategy: IDENTITY
    fields:
        open:
            type: string
            nullable: true
            length: 1
            fixed: true
            comment: ''
            default: '0'
        internet:
            type: string
            nullable: true
            length: 1
            fixed: true
            comment: ''
            default: '0'
    manyToOne:
        idProduct:
            targetEntity: Product
            cascade: {  }
            mappedBy: null
            inversedBy: null
            joinColumns:
                id_product:
                    referencedColumnName: id
            orphanRemoval: false
    lifecycleCallbacks: {  }
下面是一个存储库类:

<?php
    // src/Acme/StoreBundle/Entity/ProductRepository.php
    namespace Vendor\ProductBundle\Entity;
    use Doctrine\ORM\EntityRepository;

    class SynchronizationSettingRepository extends EntityRepository
    {
        public function findAllOrderedByName()
        {
            return $this->getEntityManager()
                ->createQuery(
                    'SELECT p FROM AcmeStoreBundle:Product p ORDER BY p.name ASC'
                )
                ->getResult();
        }
    }

我认为添加
@ORM\Entity
没有完成
那么好。只要运行
原则:generate:entities
,php
类文件就会被覆盖。您需要将
repositotyClass
添加到
YML
文件中

如果您永久地切换到注释,那些
.yml
文件(实际上是
config
中的整个
doctor
目录)除了作为生成基于注释的实体的中间文件之外,是无用的

另一件事:条令认为您有一个名称以“Repository”结尾的实体


你能给我们看一下YML文件的内容吗?如果您没有它(如您所说),则无法生成实体。您总是可以直接生成基于注释的实体(不需要
YML
中间体)

我已经用YML文件和存储库类内容更新了我的帖子。奇怪。我使用generator从数据库创建了YML文件。然后用这个YML创建实体,然后。。。仍然是相同的错误。不能在同一个捆绑包中使用映射和注释。必须是一个或另一个,如果您想要使用注释,那么您需要使config/doctor目录消失。正如@jperovic所指出的那样。拥有xxxRepository.orm.yml文件毫无意义。只有实体具有映射或注释。