/** * @param Request $request * @return Executable */ public function routeRequest(Request $request) { $path = $request->getUri()->getPath(); $routeInfo = $this->dispatcher->dispatch($request->getMethod(), $path); $dispatcherResult = $routeInfo[0]; if ($dispatcherResult === \FastRoute\Dispatcher::FOUND) { $handler = $routeInfo[1]; $vars = $routeInfo[2]; $injectionParams = InjectionParams::fromParams($vars); $injectionParams->share(new \Tier\JigBridge\RouteInfo($vars)); $executable = new Executable($handler, $injectionParams, null); $executable->setTierNumber(TierHTTPApp::TIER_GENERATE_BODY); return $executable; } else { if ($dispatcherResult === \FastRoute\Dispatcher::METHOD_NOT_ALLOWED) { //TODO - need to embed allowedMethods....theoretically. $executable = new Executable([$this, 'serve405ErrorPage']); $executable->setTierNumber(TierHTTPApp::TIER_GENERATE_BODY); return $executable; } } $executable = new Executable([$this, 'serve404ErrorPage']); $executable->setTierNumber(TierHTTPApp::TIER_GENERATE_BODY); return $executable; }
public function testExecutableAddedPreviousTier() { $executableListByTier = new ExecutableListByTier(); $fn2 = function () { $this->fail("This should never be reached."); }; $fn1 = function () use(&$executableListByTier, $fn2) { $executable = new Executable($fn2); $executable->setTierNumber(4); $executableListByTier->addExecutable($executable); }; $executableListByTier->addExecutableToTier(5, $fn1); $this->setExpectedException('Tier\\TierException', TierException::INCORRECT_VALUE); foreach ($executableListByTier as $tier => $executable) { $order[] = $tier; $callable = $executable->getCallable(); call_user_func($callable); } }
/** * */ 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; }