在链配置的名称空间上找不到Symfony 4.1存储库

时间:2018-07-12 12:20:35

标签: php repository symfony4

感谢您的回答。我在symfony 4.1上有关于存储库的问题 我使用多个实体经理。它适用于控制器。但是当我尝试使用存储库类中的用户时,出现错误。

在链配置的命名空间App \ Entity \ Management中找不到类'App \ Repository \ Management \ UserRepository',这是错误的         UserRepository类扩展ServiceEntityRepository {

/**
 * UserRepository constructor.
 */
public function __construct (ManagerRegistry $managerRegistry)
{
    parent::__construct($managerRegistry, User::class);
}

public function findDeleted()
{
    return $this->createQueryBuilder('user')
        ->addCriteria(self::createDeletedCriteria())
        ->getQuery()
        ->execute();
}

public function createDeletedCriteria()
{
    return Criteria::create()->andWhere(Criteria::expr()->neq('deletedAt', null));
}

}

我的存储库类是这样。RepositoryClass是在我的实体中定义的

@ORM\Entity(repositoryClass="App\Repository\Management\UserRepository")

和我的doctrine.yaml

    doctrine:
dbal:
    default_connection: default
    connections:
        default:
            url: '%env(resolve:DATABASE_URL)%'
            charset:  UTF8
            default_table_options:
                charset: utf8
                collate: utf8_turkish_ci
        general:
            url: '%env(resolve:GENERAL_DATABASE_URL)%'
            charset:  UTF8
            default_table_options:
                charset: utf8
                collate: utf8_turkish_ci
        management:
            url: '%env(resolve:MANAGEMENT_DATABASE_URL)%'
            charset:  UTF8
            default_table_options:
                charset: utf8
                collate: utf8_turkish_ci

    # url: '%env(resolve:DATABASE_URL)%'

orm:
    default_entity_manager: default
    auto_generate_proxy_classes: '%kernel.debug%'
    entity_managers:
        default:
            connection: default
            auto_mapping: true
            mappings:
                Main:
                    is_bundle: false
                    type: annotation
                    dir: '%kernel.project_dir%/src/Entity/Main'
                    prefix: 'App\Entity\Main'
                    alias: Main
            filters:
                softdeleteable:
                    class: Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter
                    enabled: true
        general:
            connection: general
            mappings:
                General:
                    is_bundle: false
                    type: annotation
                    dir: '%kernel.project_dir%/src/Entity/General'
                    prefix: 'App\Entity\General'
                    alias: General
            filters:
                softdeleteable:
                    class: Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter
                    enabled: true
        management:
            connection: management
            mappings:
                Management:
                    is_bundle: false
                    type: annotation
                    dir: '%kernel.project_dir%/src/Entity/Management'
                    prefix: 'App\Entity\Management'
                    alias: Management
            filters:
                softdeleteable:
                    class: Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter
                    enabled: true

0 个答案:

没有答案