Update to Drupal 8.2.0. For more information, see https://www.drupal.org/project/drupal/releases/8.2.0
This commit is contained in:
parent
2f563ab520
commit
f1c8716f57
1732 changed files with 52334 additions and 11780 deletions
61
vendor/stack/builder/README.md
vendored
61
vendor/stack/builder/README.md
vendored
|
|
@ -10,51 +10,58 @@ HttpKernelInterface decorator tree. It models it as a stack of middlewares.
|
|||
If you want to decorate a [silex](https://github.com/fabpot/Silex) app with
|
||||
session and cache middlewares, you'll have to do something like this:
|
||||
|
||||
use Symfony\Component\HttpKernel\HttpCache\Store;
|
||||
```php
|
||||
use Symfony\Component\HttpKernel\HttpCache\Store;
|
||||
|
||||
$app = new Silex\Application();
|
||||
$app = new Silex\Application();
|
||||
|
||||
$app->get('/', function () {
|
||||
return 'Hello World!';
|
||||
});
|
||||
$app->get('/', function () {
|
||||
return 'Hello World!';
|
||||
});
|
||||
|
||||
$app = new Stack\Session(
|
||||
new Symfony\Component\HttpKernel\HttpCache\HttpCache(
|
||||
$app,
|
||||
new Store(__DIR__.'/cache')
|
||||
)
|
||||
);
|
||||
$app = new Stack\Session(
|
||||
new Symfony\Component\HttpKernel\HttpCache\HttpCache(
|
||||
$app,
|
||||
new Store(__DIR__.'/cache')
|
||||
)
|
||||
);
|
||||
```
|
||||
|
||||
This can get quite annoying indeed. Stack/Builder simplifies that:
|
||||
|
||||
$stack = (new Stack\Builder())
|
||||
->push('Stack\Session')
|
||||
->push('Symfony\Component\HttpKernel\HttpCache\HttpCache', new Store(__DIR__.'/cache'));
|
||||
|
||||
$app = $stack->resolve($app);
|
||||
```php
|
||||
$stack = (new Stack\Builder())
|
||||
->push('Stack\Session')
|
||||
->push('Symfony\Component\HttpKernel\HttpCache\HttpCache', new Store(__DIR__.'/cache'));
|
||||
|
||||
$app = $stack->resolve($app);
|
||||
```
|
||||
As you can see, by arranging the layers as a stack, they become a lot easier
|
||||
to work with.
|
||||
|
||||
In the front controller, you need to serve the request:
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
$request = Request::createFromGlobals();
|
||||
$response = $app->handle($request)->send();
|
||||
$app->terminate($request, $response);
|
||||
```php
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
$request = Request::createFromGlobals();
|
||||
$response = $app->handle($request)->send();
|
||||
$app->terminate($request, $response);
|
||||
```
|
||||
Stack/Builder also supports pushing a `callable` on to the stack, for situations
|
||||
where instantiating middlewares might be more complicated. The `callable` should
|
||||
accept a `HttpKernelInterface` as the first argument and should also return a
|
||||
`HttpKernelInterface`. The example above could be rewritten as:
|
||||
|
||||
$stack = (new Stack\Builder())
|
||||
->push('Stack\Session')
|
||||
->push(function ($app) {
|
||||
$cache = new HttpCache($app, new Store(__DIR__.'/cache'));
|
||||
return $cache;
|
||||
});
|
||||
```php
|
||||
$stack = (new Stack\Builder())
|
||||
->push('Stack\Session')
|
||||
->push(function ($app) {
|
||||
$cache = new HttpCache($app, new Store(__DIR__.'/cache'));
|
||||
return $cache;
|
||||
})
|
||||
;
|
||||
```
|
||||
|
||||
## Inspiration
|
||||
|
||||
|
|
|
|||
Reference in a new issue