Cannot instantiate custom repository

Hello everyone

I tried to get the instance of custom_entity repository by calling **this-\>container-\>get('custom\_entity.repository')** inside base class of example plugin from GitHub repository (GitHub - shopware/swag-docs-custom-entity: Shopware Platform example plugin from the documentation.).

When I run install command inside the development store following error occurred: You have requested a non-existent service "custom_entity.repository". Migration is executed successfully.

Is it possible to get the instance of this repository inside the base plugin class?

Hello Ivan,

in general it is possible to get the repository services from the container in your plugin base class.

But you try to get a repository which is provided by your plugin. The container is only build with installed and activated plugin.
So in the request where you try to install/activate your plugin, the service is of course not in the container. It would be first available in the very next request. 

Best regards from Schöppingen

cool Michael Telgmann

Hello Michael,

Thank You for your quick answer.