/** * This method is called by Splot Framework during the run phase, so right before it will * handle a request or a CLI command. * * This is a place where all services from all modules have been registered and the whole app * is fully bootstrapped and fully configured so you can add some global application-wide * logic or behavior here. */ public function run() { parent::run(); }
/** * Runs the application. */ public function run() { if ($this->container->getParameter('mode') !== Framework::MODE_CONSOLE) { throw new \RuntimeException('Genry can only be run in console!'); } parent::run(); }
/** * Runs the application in context of the given mode and using the given runner function. * * The last argument is a callback that will be invoked by this method and it should contain * execution logic specific to the given mode. * * Returns whatever the runner returns (which should be a result of running the application). * * @param AbstractApplication $application Application to be ran. * @param int $mode Mode in which the application should be ran. * One of the `Framework::MODE_*` constants. * @param callable $runner Closure that is responsible for actually running * the application in appropriate mode. * @return mixed */ protected function doRunApplication(AbstractApplication $application, $mode, $runner) { $timer = new Timer(); $container = $application->getContainer(); // container can now know in what mode its running $container->setParameter('mode', $mode); // run modules and the app foreach ($application->getModules() as $module) { $module->run(); } $application->run(); // run using the passed runner $result = call_user_func($runner); // log benchmark data $time = $timer->stop(); $memory = $timer->getMemoryUsage(); $container->get('splot.logger')->debug('Application run phase in mode "{mode}" finished in {time} ms and used {memory} memory.', array('mode' => self::modeName($mode), 'env' => $container->getParameter('env'), 'debug' => $container->getParameter('debug'), 'time' => $time, 'memory' => StringUtils::bytesToString($memory), '@stat' => 'splot.run.' . self::modeName($mode), '@time' => $time, '@memory' => $memory)); return $result; }