public static function routeCommand(ConsoleApplication $console) { // TODO - currently in PHP it is impossible to make a constructor of a child class // have a constructor that has more restricted visibility than then parent class. // In an ideal world, ConsoleApplication would be a child class that does not have a // default constructor, as that would prevent 'accidental' insertion of an unitialized // object. // However that is not currently possible, and would require an RFC to change. //Figure out what Command was requested. try { $parsedCommand = $console->parseCommandLine(); } catch (\Exception $e) { //@TODO change to just catch parseException when that's implemented $output = new BufferedOutput(); $console->renderException($e, $output); echo $output->fetch(); exit(-1); } $output = $parsedCommand->getOutput(); $formatter = $output->getFormatter(); $formatter->setStyle('question', new OutputFormatterStyle('blue')); $formatter->setStyle('info', new OutputFormatterStyle('blue')); $questionHelper = new QuestionHelper(); $questionHelper->setHelperSet($console->getHelperSet()); $injectionParams = InjectionParams::fromParams($parsedCommand->getParams()); $executable = new Executable($parsedCommand->getCallable(), $injectionParams); $executable->setAllowedToReturnNull(true); return $executable; }
/** * */ public function run() { /** @noinspection PhpUndefinedMethodInspection */ \ImagickDemo\Imagick\functions::load(); \ImagickDemo\ImagickDraw\functions::load(); \ImagickDemo\ImagickPixel\functions::load(); \ImagickDemo\ImagickKernel\functions::load(); \ImagickDemo\ImagickPixelIterator\functions::load(); \ImagickDemo\Tutorial\functions::load(); $executableList = []; $imageGenerateExecutable = new Executable([$this, 'actuallyRun']); $imageGenerateExecutable->setTierNumber(\Tier\TierCLIApp::TIER_LOOP); $imageGenerateExecutable->setAllowedToReturnNull(true); $executableList[] = $imageGenerateExecutable; $timeoutExecutable = new Executable([$this, 'timeoutCheck']); $timeoutExecutable->setTierNumber(\Tier\TierCLIApp::TIER_LOOP); $executableList[] = $timeoutExecutable; return $executableList; }