Exemple #1
0
 /**
  * Replaces the event name with a redirect event if the url 
  * hasn't a slash at the end of the url.
  * 
  * @access public
  * @param \Zepi\Turbo\Framework $framework
  * @param \Zepi\Turbo\Request\RequestAbstract $request
  * @param \Zepi\Turbo\Response\Response $response
  * @param mixed $value
  * @return mixed
  */
 public function execute(Framework $framework, RequestAbstract $request, Response $response, $value = null)
 {
     if (!$request instanceof WebRequest) {
         return $value;
     }
     $fullUrl = $request->getRequestedUrl();
     $urlParts = parse_url($fullUrl);
     if ($urlParts == false) {
         return $value;
     }
     $urlParts = $this->verifyPath($urlParts);
     $completeUrl = $response->buildUrl($urlParts);
     if ($completeUrl !== $request->getRequestedUrl()) {
         $response->redirectTo($completeUrl);
         return null;
     }
     return $value;
 }