ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Slim Namespace Reference

Slim Framework (https://slimframework.com) More...

Namespaces

 Exception
 Slim Framework (https://slimframework.com)
 
 Handlers
 Slim Framework (https://slimframework.com)
 
 Http
 Slim Framework (https://slimframework.com)
 
 Interfaces
 Slim Framework (https://slimframework.com)
 

Data Structures

class  App
 
class  CallableResolver
 This class resolves a string of the format 'class:method' into a closure that can be dispatched. More...
 
class  Collection
 Collection. More...
 
class  Container
 
class  DefaultServicesProvider
 Slim's default Service Provider. More...
 
class  DeferredCallable
 
class  Routable
 
class  Route
 Route. More...
 
class  RouteGroup
 
class  Router
 Router. More...
 

Functions

 addMiddleware (callable $callable)
 Add middleware. More...
 
 seedMiddlewareStack (callable $kernel=null)
 Seed middleware stack with first callable. More...
 

Variables

trait MiddlewareAwareTrait
 Middleware. More...
 
 $middlewareLock = false
 

Detailed Description

Slim Framework (https://slimframework.com)

A collector for Routable objects with a common middleware stack.

A routable, middleware-aware object.

Router Interface.

Route Interface.

RouteGroup Interface.

Headers Interface.

Environment Interface.

Cookies Interface.

Collection Interface.

Resolves a callable.

Copyright (c) 2011-2017 Josh Lockhart https://github.com/slimphp/Slim/blob/3.x/LICENSE.md (MIT License) 3.0.0

Function Documentation

◆ addMiddleware()

Slim\addMiddleware ( callable  $callable)
protected

Add middleware.

This method prepends new middleware to the application middleware stack.

Parameters
callable$callableAny callable that accepts three arguments:
  1. A Request object
  2. A Response object
  3. A "next" middleware callable
Returns
static
Exceptions
RuntimeExceptionIf middleware is added while the stack is dequeuing
UnexpectedValueExceptionIf the middleware doesn't return a Psr

Definition at line 53 of file MiddlewareAwareTrait.php.

References $response, $result, and seedMiddlewareStack().

Referenced by Slim\App\add(), and Slim\Route\finalize().

54  {
55  if ($this->middlewareLock) {
56  throw new RuntimeException('Middleware can’t be added once the stack is dequeuing');
57  }
58 
59  if (is_null($this->tip)) {
60  $this->seedMiddlewareStack();
61  }
62  $next = $this->tip;
63  $this->tip = function (
64  ServerRequestInterface $request,
65  ResponseInterface $response
66  ) use (
67  $callable,
68  $next
69  ) {
70  $result = call_user_func($callable, $request, $response, $next);
71  if ($result instanceof ResponseInterface === false) {
72  throw new UnexpectedValueException(
73  'Middleware must return instance of \Psr\Http\Message\ResponseInterface'
74  );
75  }
76 
77  return $result;
78  };
79 
80  return $this;
81  }
$result
seedMiddlewareStack(callable $kernel=null)
Seed middleware stack with first callable.
$response
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ seedMiddlewareStack()

Slim\seedMiddlewareStack ( callable  $kernel = null)
protected

Seed middleware stack with first callable.

Parameters
callable$kernelThe last item to run as middleware
Exceptions
RuntimeExceptionif the stack is seeded more than once

Definition at line 90 of file MiddlewareAwareTrait.php.

References $response.

Referenced by addMiddleware().

91  {
92  if (!is_null($this->tip)) {
93  throw new RuntimeException('MiddlewareStack can only be seeded once.');
94  }
95  if ($kernel === null) {
96  $kernel = $this;
97  }
98  $this->tip = $kernel;
99  }
+ Here is the caller graph for this function:

Variable Documentation

◆ $middlewareLock

Slim\$middlewareLock = false
protected

Definition at line 37 of file MiddlewareAwareTrait.php.

◆ MiddlewareAwareTrait

trait Slim\MiddlewareAwareTrait
Initial value:
{
protected $tip

Middleware.

This is an internal class that enables concentric middleware layers. This class is an implementation detail and is used only inside of the Slim application; it is not visible to—and should not be used by—end users.

Definition at line 24 of file MiddlewareAwareTrait.php.