コード例 #1
0
ファイル: Router.php プロジェクト: Zvax/Tier
 /**
  * @param Request $request
  * @return Executable
  */
 public function routeRequest(Request $request)
 {
     $path = $request->getPath();
     $queryPosition = strpos($path, '?');
     if ($queryPosition !== false) {
         $path = substr($path, 0, $queryPosition);
     }
     $routeInfo = $this->dispatcher->dispatch($request->getMethod(), $path);
     $dispatcherResult = $routeInfo[0];
     if ($dispatcherResult == \FastRoute\Dispatcher::FOUND) {
         $handler = $routeInfo[1];
         $vars = $routeInfo[2];
         $params = InjectionParams::fromParams($vars);
         return new Executable($handler, $params, null);
     } else {
         if ($dispatcherResult == \FastRoute\Dispatcher::METHOD_NOT_ALLOWED) {
             //TODO - need to embed allowedMethods....theoretically.
             return new Executable([$this, 'serve405ErrorPage']);
         }
     }
     $templateName = $this->templateExists($path, $this->jigConfig);
     if ($templateName != false) {
         return $this->tierJig->createJigExecutable($templateName);
     }
     return new Executable([$this, 'serve404ErrorPage']);
 }
コード例 #2
0
ファイル: appFunctions.php プロジェクト: finelinePG/imagick
function createImageTask(VariableMap $variableMap, ImagickTaskQueue $taskQueue, PageInfo $pageInfo, Request $request, Response $response, $customImage, $params)
{
    $job = $variableMap->getVariable('job', false);
    if ($job === false) {
        if ($taskQueue->isActive() == false) {
            //Queue isn't active - don't bother queueing a task
            return false;
        }
        $task = new \ImagickDemo\Queue\ImagickTask($pageInfo, $params, $customImage, $request->getPath());
        $taskQueue->addTask($task);
    }
    if ($variableMap->getVariable('noredirect') == true) {
        return new \ImagickDemo\Response\ErrorResponse(503, "image still processing {$job} is " . $job);
    }
    $caching = new \Room11\Caching\LastModified\Disabled();
    foreach ($caching->getHeaders(time()) as $key => $value) {
        $response->addHeader($key, $value);
    }
    $response->setStatus(420);
    return new TextBody("Image is generating.");
}