Skip to content

Commit

Permalink
fix routing pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Dec 21, 2016
1 parent b7d2a65 commit 7573abf
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 26 deletions.
19 changes: 14 additions & 5 deletions src/Illuminate/Pipeline/Pipeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,26 @@ public function via($method)
*/
public function then(Closure $destination)
{
$destination = function ($passable) use ($destination) {
return $destination($passable);
};

$pipeline = array_reduce(
array_reverse($this->pipes), $this->carry(), $destination
array_reverse($this->pipes), $this->carry(), $this->prepareDestination($destination)
);

return $pipeline($this->passable);
}

/**
* Get the final piece of the Closure onion.
*
* @param \Closure $destination
* @return \Closure
*/
protected function prepareDestination(Closure $destination)
{
return function ($passable) use ($destination) {
return $destination($passable);
};
}

/**
* Get a Closure that represents a slice of the application onion.
*
Expand Down
43 changes: 22 additions & 21 deletions src/Illuminate/Routing/Pipeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,37 @@
*/
class Pipeline extends BasePipeline
{
/**
* Get the final piece of the Closure onion.
*
* @param \Closure $destination
* @return \Closure
*/
protected function prepareDestination(Closure $destination)
{
return function ($passable) use ($destination) {
try {
return $destination($passable);
} catch (Exception $e) {
return $this->handleException($passable, $e);
} catch (Throwable $e) {
return $this->handleException($passable, new FatalThrowableError($e));
}
};
}

/**
* Get a Closure that represents a slice of the application onion.
*
* @return \Closure
*/
protected function getSlice()
protected function carry()
{
return function ($stack, $pipe) {
return function ($passable) use ($stack, $pipe) {
try {
$slice = parent::getSlice();
$slice = parent::carry();

$callable = $slice($stack, $pipe);

return $callable($passable);
Expand All @@ -40,25 +60,6 @@ protected function getSlice()
};
}

/**
* Get the initial slice to begin the stack call.
*
* @param \Closure $destination
* @return \Closure
*/
protected function getInitialSlice(Closure $destination)
{
return function ($passable) use ($destination) {
try {
return $destination($passable);
} catch (Exception $e) {
return $this->handleException($passable, $e);
} catch (Throwable $e) {
return $this->handleException($passable, new FatalThrowableError($e));
}
};
}

/**
* Handle the given exception.
*
Expand Down

0 comments on commit 7573abf

Please sign in to comment.