I want to a few terminal commands to my Symfony2 application. I\'ve gone through the example in the cookbook, but I couldn\'t find out how to access my settings, my entity m
I know that Matt's answer solved the question, But if you've more than one entity manager, you can use this:
Make model.xml with:
Then load this file in your DI extension
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('model.xml');
Then you can use it anywhere. In Console Command execute:
$em = $this->getContainer()->get('EM_NAME.entity_manager');
and don't forget at end to :
$em->flush();
You can now use it as a argument in another service in services.yml:
services:
SOME_SERVICE:
class: %parameter.class%
arguments:
- @EM_NAME.entity_manager
Hope this help someone.