ivanbivanb MemberComments: 1 Received thanks: 0 Member since: September 10

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 (https://github.com/shopware/swag-docs-custom-entity).

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?

1 Answer

  • Michael TelgmannMichael Telgmann ModeratorComments: 987 Received thanks: 281 Member since: June 2014

    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

    Quote
    Accepted Answer
  • Accepted Answer

Answers

  • Michael TelgmannMichael Telgmann ModeratorComments: 987 Received thanks: 281 Member since: June 2014

    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

    Quote
    Accepted Answer
  • ivanbivanb MemberComments: 1 Received thanks: 0 Member since: September 10

    Hello Michael,

    Thank You for your quick answer.

Sign In or Register to comment.