Exemplo n.º 1
0
 /** Generates and returns the response from the current route */
 public function response()
 {
     if (!$this->route) {
         return null;
     }
     foreach ($this->route->routines as $routine) {
         if ($routine instanceof ProxyableBy && false === $this->routineCall('by', $this->method, $routine, $this->params)) {
             return false;
         }
     }
     $response = $this->route->runTarget($this->method, $this->params);
     if ($response instanceof AbstractRoute) {
         return $this->forward($response);
     }
     $proxyResults = array();
     foreach ($this->route->routines as $routine) {
         if ($routine instanceof ProxyableThrough) {
             $proxyResults[] = $this->routineCall('through', $this->method, $routine, $this->params);
         }
     }
     if (!empty($proxyResults)) {
         foreach ($proxyResults as $proxyCallback) {
             if (is_callable($proxyCallback)) {
                 $response = $proxyCallback($response);
             }
         }
     }
     return $response;
 }
 /** Generates and returns the response from the current route */
 public function response()
 {
     try {
         if (!$this->route instanceof AbstractRoute) {
             return null;
         }
         $errorHandler = $this->prepareForErrorForwards();
         $result = $this->processPreRoutines();
         if (!is_null($result)) {
             return $result;
         }
         $response = $this->route->runTarget($this->method, $this->params);
         if ($response instanceof AbstractRoute) {
             return $this->forward($response);
         }
         $response = $this->processPosRoutines($response);
         $result = $this->forwardErrors($errorHandler);
         if (!is_null($result)) {
             return $result;
         }
         return $response;
     } catch (\Exception $e) {
         if (!($caught = $this->catchExceptions($e))) {
             throw $e;
         }
         return $caught;
     }
 }