serveRedirect() public method

If a redirect exists at this path, serve it.
public serveRedirect ( string $uri ) : boolean
$uri string
return boolean
Ejemplo n.º 1
0
 /**
  * This interrupts requests if all else fails.
  * @param string[] ...$args
  * @return void
  * @throws CustomPageNotFoundException
  */
 public function routeNotFound(...$args)
 {
     if (!\is1DArray($args)) {
         throw new CustomPageNotFoundException(\__('Invalid arguments'));
     }
     $dirs = $args;
     $file = \array_pop($dirs);
     // First: Do we have a custom page at this endpoint?
     try {
         if ($this->serveCustomPage($file, $dirs)) {
             return;
         }
     } catch (CustomPageNotFoundException $ex) {
         $this->log('Custom page not found', LogLevel::INFO, ['cabin' => $this->cabin, 'dirs' => $dirs, 'exception' => \Airship\throwableToArray($ex), 'file' => $file]);
     }
     // Second: Is there a redirect at this endpoint?
     try {
         $path = \implode('/', $args);
         if ($this->pages->serveRedirect($path)) {
             return;
         }
     } catch (RedirectException $ex) {
         $this->log('Redirect missed', LogLevel::INFO);
     }
     \http_response_code(404);
     // Finally: Return a 4o4
     $this->lens('404');
     return;
 }