symfony - How to get command argument outside command class? -


To achieve:

  class LoadUserData implements FixtureInterface, ContainerAwareInterface {Private $ container; / ** * {@inheritDoc} * / Public Function Load (ObjectManager $ Manager) {} Public Function setContainer (ContainerInterface $ Container = Faucet) {$ this- & gt; Container = $ Container; }}  

Any suggestions?

So if you've expanded Principle: Bundle \ FixturesBundle \ Command \ LoadDataFixtures DoctrineCommand and then you can set the value that is passed as a container parameter, managed to add an additional logic

 < Code> & lt ;? Php namespace is your \ bundle \ command; Use Symfony \ Component \ Console \ Input \ InputInterface; Use Symfony \ Component \ Console \ Output \ OutputInterface; Use the principle \ bundle \ fixture bundle \ command \ loaded data fixtures dottrin command; Class LoadDataFixersMododatDataFixContentDococrydom Commands Extended {/ ** * {@ Inherit Doc} * / Configure Protected Function () {parent :: configure (); $ This- & gt; Add option ('custom option', blank, input options :: VALUE_OPTIONAL, 'your custom option'); } / ** * {@inheritDoc} * / Perform the protected function (InputInterface $ input, OutputInterface $ production) {$ this- & gt; GetContainer () - & gt; SetParameter ('custom option', $ input- & gt; getOption ('custom option')); Original: Execution ($ input, $ output); }}  

Then get the container parameter in its fixtures class.

Load Loader application applies to FixtureInterface, ContainerAwareInterface {/ ** * If you have PHP 5.4, or greater then you can use this attribute to apply ContainerAwareInterface * * @ Link https://github.com/symfony/symfony/blob/master/src/Symfony/Component/DependencyInjection/ContainerAwareTrait.php * / Use \ Symfony \ Component \ DependencyInjection \ ContainerAwareTrait; / ** * {@ Inherit Doc} * / Public Function Load (Object Manager Administrator) {$ customOption = $ this- & gt; Container-> GetParameter ('custom-choice'); /// ....}}

Comments