It makes sense to wrap the logic inside the Doctrine listener around:
if ($this->enabled) {
Thus, everyone can understand that logic can be disabled or not.
You can use the parameter to enable or disable the code (see http://symfony.com/doc/current/service_container/parameters.html ).
my_doctrine_listener_enabled: true
In the command, you set the value to false:
$container->setParameter('my_doctrine_listener_enabled', false);
Since the parameter is changed at run time, I recommend that you not use it through the DIC, but through
$container->getParameter('my_doctrine_listener_enabled')
Or another approach could be:
- Create an "enabled" variable inside a Doctrine listener
- Doctrine
$this->myListener->enabled = false