Move into nested docroot
This commit is contained in:
parent
83a0d3a149
commit
c8b70abde9
13405 changed files with 0 additions and 0 deletions
63
web/vendor/stack/builder/src/Stack/Builder.php
vendored
Normal file
63
web/vendor/stack/builder/src/Stack/Builder.php
vendored
Normal file
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
|
||||
namespace Stack;
|
||||
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
|
||||
class Builder
|
||||
{
|
||||
private $specs;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->specs = new \SplStack();
|
||||
}
|
||||
|
||||
public function unshift(/*$kernelClass, $args...*/)
|
||||
{
|
||||
if (func_num_args() === 0) {
|
||||
throw new \InvalidArgumentException("Missing argument(s) when calling unshift");
|
||||
}
|
||||
|
||||
$spec = func_get_args();
|
||||
$this->specs->unshift($spec);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function push(/*$kernelClass, $args...*/)
|
||||
{
|
||||
if (func_num_args() === 0) {
|
||||
throw new \InvalidArgumentException("Missing argument(s) when calling push");
|
||||
}
|
||||
|
||||
$spec = func_get_args();
|
||||
$this->specs->push($spec);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function resolve(HttpKernelInterface $app)
|
||||
{
|
||||
$middlewares = array($app);
|
||||
|
||||
foreach ($this->specs as $spec) {
|
||||
$args = $spec;
|
||||
$firstArg = array_shift($args);
|
||||
|
||||
if (is_callable($firstArg)) {
|
||||
$app = $firstArg($app);
|
||||
} else {
|
||||
$kernelClass = $firstArg;
|
||||
array_unshift($args, $app);
|
||||
|
||||
$reflection = new \ReflectionClass($kernelClass);
|
||||
$app = $reflection->newInstanceArgs($args);
|
||||
}
|
||||
|
||||
array_unshift($middlewares, $app);
|
||||
}
|
||||
|
||||
return new StackedHttpKernel($app, $middlewares);
|
||||
}
|
||||
}
|
37
web/vendor/stack/builder/src/Stack/StackedHttpKernel.php
vendored
Normal file
37
web/vendor/stack/builder/src/Stack/StackedHttpKernel.php
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
namespace Stack;
|
||||
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\HttpKernel\TerminableInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class StackedHttpKernel implements HttpKernelInterface, TerminableInterface
|
||||
{
|
||||
private $app;
|
||||
private $middlewares = array();
|
||||
|
||||
public function __construct(HttpKernelInterface $app, array $middlewares)
|
||||
{
|
||||
$this->app = $app;
|
||||
$this->middlewares = $middlewares;
|
||||
}
|
||||
|
||||
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
|
||||
{
|
||||
return $this->app->handle($request, $type, $catch);
|
||||
}
|
||||
|
||||
public function terminate(Request $request, Response $response)
|
||||
{
|
||||
$prevKernel = null;
|
||||
foreach ($this->middlewares as $kernel) {
|
||||
// if prev kernel was terminable we can assume this middleware has already been called
|
||||
if (!$prevKernel instanceof TerminableInterface && $kernel instanceof TerminableInterface) {
|
||||
$kernel->terminate($request, $response);
|
||||
}
|
||||
$prevKernel = $kernel;
|
||||
}
|
||||
}
|
||||
}
|
Reference in a new issue