/** * @inheritdoc */ public function doRun(InputInterface $input, OutputInterface $output) { // Define the running environment and initialize the container. $env = $input->getParameterOption(array('-e', '--env'), 'dev'); $this->container->getApplicationBag()->setEnv($env); $this->container->getConsoleBag()->set('input', $input)->set('output', $output); $this->container->initialize(); // Add commands. foreach ($this->container->getCommandBag()->values() as $command) { $this->add($command); } // Dispatch pre run event. $dispatcher = $this->container->getServiceBag()->getDispatcher(); $dispatcher->dispatch(Events::PRE_RUN, new PreRunEvent($this->container)); // Run application. $result = parent::doRun($input, $output); // Dispatch post run event. $dispatcher->dispatch(Events::POST_RUN, new PostRunEvent($this->container, $result)); return $result; }