You are here

public function Builder::resolve in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/stack/builder/src/Stack/Builder.php \Stack\Builder::resolve()

File

vendor/stack/builder/src/Stack/Builder.php, line 40

Class

Builder

Namespace

Stack

Code

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