R
R
Roman Hinex2015-02-02 15:20:36
symfony
Roman Hinex, 2015-02-02 15:20:36

Symfony2: How to use doctrine in DependencyInjection Extension?

When the bundle is initialized in the DependencyInjection/SeamplebundleExtension.php file, its configuration is twitching. At this point, I add a certain parameter there. The value of this parameter must be taken from the database. But I can not pull the doctrine or the entity itself. What are some ideas?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
keltanas, 2015-02-03
@HiNeX

Roman Hinex dude, first read the container documentation, specifically symfony.com/doc/current/components/dependency_inje... and symfony.com/doc/current/components/dependency_inje... , and then think about something like what do you want to fit with what you read?
Your question is just from ignorance of the materiel.
Let me tell you, during the compilation of the container, all services in it are represented as objects of the Definition type, these are objects containing the configuration according to which the service will have to be created in the future, after the container has already been compiled. Until compilation is complete, you have no idea how any of the services can be changed by subsequent passes.
The extension generally operates only in the area of ​​its bundle with a pure copy of the container, which knows only about the services of the bundle and knows nothing about other bundles. The only task of the extension is to assemble the bundle config. Merging of configs happens already during compilation.
But even then, services are presented only in the form of Definition and cannot be instantiated, because other passes can change them (and adjust parameters as well).
Then write a separate service to work with dynamic configuration and use it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question