Exemplo n.º 1
0
 /**
  * Tries to match a URL path with a set of routes.
  *
  * If the matcher can not find information, it must throw one of the
  * exceptions documented below.
  *
  * @param string $pathinfo The path info to be parsed (raw format, i.e. not
  *                         urldecoded)
  *
  * @return array An array of parameters
  *
  * @throws ResourceNotFoundException If the resource could not be found
  * @throws MethodNotAllowedException If the resource was found but the
  *                                   request method is not allowed
  */
 public function match($pathinfo)
 {
     $urlMatcher = new UrlMatcher($this->routeCollection, $this->getContext());
     $result = $urlMatcher->match($pathinfo);
     if (!empty($result)) {
         try {
             // The route matches, now check if it actually exists
             $result['content'] = $this->contentManager->findActiveBySlug($result['slug']);
         } catch (NoResultException $e) {
             try {
                 //is it directory index
                 if (substr($result['slug'], -1) == '/' || $result['slug'] == '') {
                     $result['content'] = $this->contentManager->findActiveBySlug($result['slug'] . 'index');
                 } else {
                     if ($this->contentManager->findActiveBySlug($result['slug'] . '/index')) {
                         $redirect = new RedirectResponse($this->request->getBaseUrl() . "/" . $result['slug'] . '/');
                         $redirect->sendHeaders();
                         exit;
                     }
                 }
             } catch (NoResultException $ex) {
                 try {
                     $result['content'] = $this->contentManager->findActiveByAlias($result['slug']);
                 } catch (NoResultException $ex) {
                     throw new ResourceNotFoundException('No page found for slug ' . $pathinfo);
                 }
             }
         }
     }
     return $result;
 }
Exemplo n.º 2
0
 /**
  * Redirect Response.
  *
  * @param string $url
  * @param int    $status
  * @param array  $headers
  */
 public static function redirect($url, $status = 302, $headers = array())
 {
     $redirect = new RedirectResponse($url, $status, $headers);
     $redirect->sendHeaders();
     die;
 }
Exemplo n.º 3
0
 /**
  * (non-PHPdoc)
  * @see TheTwelve\Foursquare.Redirector::redirect()
  */
 public function redirect($uri)
 {
     $response = new HttpFoundation\RedirectResponse($uri);
     $response->sendHeaders();
     return $response;
 }