G
G
grabbee2020-04-04 20:07:56
symfony
grabbee, 2020-04-04 20:07:56

How to add repositories from a bundle in Symfony?

I tried to separate the common code into a separate bundle. Entity got there along with Repository

entity repository implements "Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepositoryInterface", but its service could not be found. Make sure the service exists and is tagged with "doctrine.repository_service".


If for each repository to register a tag in `services.yml` separately, then it works

Vendor\MyBundle\Repository\ClassRepository:
    tags: ['doctrine.repository_service']


Can they be added all at once?
For example `resource: '../src/Repository'` does not work for a bundle.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
OnYourLips, 2020-04-04
@OnYourLips

Through autowiring and wildcards.

G
grabbee, 2020-04-04
@grabbee

If you have a bundle you have to explain to symfony you use autowire again. And the setup is exactly the same, except for two more ../ dots.

Works: But why exactly `../../` - what does it count from?.. resource: '../../Repository'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question