Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663

This commit is contained in:
Greg Anderson 2015-10-08 11:40:12 -07:00
parent eb34d130a8
commit f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions

View 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);
}
}