From 5c7ab07590e4797ce31ea20209b3d9665d8fc8b5 Mon Sep 17 00:00:00 2001 From: Leandro Menezes dos anjos Date: Fri, 11 Mar 2016 14:44:25 -0300 Subject: [PATCH] Improvements in Request Class --- library/Respect/Rest/Request.php | 59 +++++++++++++++----------------- 1 file changed, 28 insertions(+), 31 deletions(-) diff --git a/library/Respect/Rest/Request.php b/library/Respect/Rest/Request.php index e8bde2d..e7ef1d1 100644 --- a/library/Respect/Rest/Request.php +++ b/library/Respect/Rest/Request.php @@ -107,21 +107,21 @@ protected function processPreRoutines() foreach ($this->route->routines as $routine) { if (!$routine instanceof ProxyableBy) { continue; - } else { - $result = $this->routineCall( - 'by', - $this->method, - $routine, - $this->params - ); - - //Routine returned an instance, let's forward it - if ($result instanceof AbstractRoute) { - return $this->forward($result); - } elseif (false === $result) { - return false; - } } + $result = $this->routineCall( + 'by', + $this->method, + $routine, + $this->params + ); + + //Routine returned an instance, let's forward it + if ($result instanceof AbstractRoute) { + return $this->forward($result); + } elseif (false === $result) { + return false; + } + } } @@ -137,32 +137,29 @@ protected function processPreRoutines() */ protected function processPosRoutines($response) { - $proxyResults = array(); - - foreach ($this->route->routines as $routine) { + foreach ($this->route->routines as $routine) { if ($routine instanceof ProxyableThrough) { - $proxyResults[] = $this->routineCall( + $proxyCallback = $this->routineCall( 'through', $this->method, $routine, $this->params ); - } - } - //Some routine returned a callback as its result. Let's run - //these callbacks on our actual response. - //This is mainly used by accept() and similar ones. - foreach ($proxyResults as $proxyCallback) { - if (is_callable($proxyCallback)) { - $response = call_user_func_array( - $proxyCallback, - array($response) - ); + //Some routine returned a callback as its result. Let's run + //these callbacks on our actual response. + //This is mainly used by accept() and similar ones. + + if (is_callable($proxyCallback)) { + $response = call_user_func_array( + $proxyCallback, + array($response) + ); + } } - } + } - return $response; + return $response; } /**