shakaran

container

Sep 26th, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.40 KB | None | 0 0
  1. <?php
  2.  
  3. // YourCommand.php
  4. use Symfony\Component\DependencyInjection\ContainerInterface;
  5.  
  6. private $container;
  7.  
  8. public function __construct(ContainerInterface $container)
  9. {
  10.     parent::__construct();
  11.     $this->container = $container;
  12. }
  13.  
  14. protected function execute(InputInterface $input, OutputInterface $output)
  15. {
  16.     $em = $this->container->get('doctrine')->getManager();
  17.  
  18.     // do stuff...
  19. }
Advertisement
Add Comment
Please, Sign In to add comment