Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions src/Klein/Klein.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,15 @@ class Klein
protected $app;


/**
* Skip Counter
*
* @type int
*/
protected $skips = 0;



/**
* Methods
*/
Expand Down Expand Up @@ -585,18 +594,29 @@ public function dispatch(

// Handle our response callback
try {

if($this->skips == -1) break;
if($this->skips > 0) {
$this->skips--;
continue;
}

$this->handleRouteCallback($route, $matched, $methods_matched);

} catch (DispatchHaltedException $e) {
switch ($e->getCode()) {
case DispatchHaltedException::SKIP_THIS:
continue 2;
break;

/*
case DispatchHaltedException::SKIP_NEXT:
$skip_num = $e->getNumberOfSkips();
break;
case DispatchHaltedException::SKIP_REMAINING:
break 2;
*/

default:
throw $e;
}
Expand Down Expand Up @@ -1095,10 +1115,11 @@ public function skipThis()
*/
public function skipNext($num = 1)
{
$skip = new DispatchHaltedException(null, DispatchHaltedException::SKIP_NEXT);
$skip->setNumberOfSkips($num);
//$skip = new DispatchHaltedException(null, DispatchHaltedException::SKIP_NEXT);
//$skip->setNumberOfSkips($num);

throw $skip;
//throw $skip;
$this->skips = $num;
}

/**
Expand All @@ -1109,7 +1130,8 @@ public function skipNext($num = 1)
*/
public function skipRemaining()
{
throw new DispatchHaltedException(null, DispatchHaltedException::SKIP_REMAINING);
//throw new DispatchHaltedException(null, DispatchHaltedException::SKIP_REMAINING);
$this->skips = -1; //Remaining
}

/**
Expand Down