Skip to content

Instantly share code, notes, and snippets.

@iolloyd
Created August 8, 2016 15:10
Show Gist options
  • Save iolloyd/1223ac7fc6a2cb23f19f8a2f387a6fed to your computer and use it in GitHub Desktop.
Save iolloyd/1223ac7fc6a2cb23f19f8a2f387a6fed to your computer and use it in GitHub Desktop.
How slim v3 makes the app available in the callback
public function add(\Slim\Middleware $newMiddleware)
{
if(in_array($newMiddleware, $this->middleware)) {
$middleware_class = get_class($newMiddleware);
throw new \RuntimeException("Circular Middleware setup detected. Tried to queue the same Middleware instance ({$middleware_class}) twice.");
}
$newMiddleware->setApplication($this);
$newMiddleware->setNextMiddleware($this->middleware[0]);
array_unshift($this->middleware, $newMiddleware);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment