8000 [RFC][DependencyInjection][HttpKernel] Kernel as a service by ro0NL · Pull Request #19606 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[RFC][DependencyInjection][HttpKernel] Kernel as a service #19606

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added kernel/bundle service objects
  • Loading branch information
ro0NL committed Aug 12, 2016
commit b75416a74e56e1ba9651bc68a709f4da07ded111
68 changes: 68 additions & 0 deletions src/Symfony/Component/HttpKernel/Service/Bundle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\HttpKernel\Service;

/**
* The bundle service represents a bundle as a service throughout the ecosystem.
*
* @author Roland Franssen <franssen.roland@gmail.com>
*/
class Bundle
{
private $name;
private $namespace;
private $className;
private $path;
< 10000 /td> private $parent;

/**
* Constructor.
*
* @param string $name
* @param string $namespace
* @param string $className
* @param string $path
* @param Bundle|null $parent
*/
public function __construct($name, $namespace, $className, $path, Bundle $parent = null)
{
$this->name = $name;
$this->className = $className;
$this->path = $path;
$this->parent = $parent;
}

final public function getName()
{
return $this->name;
}

final public function getNamespace()
{
return $this->namespace;
}

final public function getClassName()
{
return $this->className;
}

final public function getPath()
{
return $this->path;
}

final public function getParent()
{
return $this->parent;
}
}
68 changes: 68 additions & 0 deletions src/Symfony/Component/HttpKernel/Service/Kernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\HttpKernel\Service;

/**
* The kernel service represents a kernel as a service throughout the ecosystem.
*
* @author Roland Franssen <franssen.roland@gmail.com>
*/
class Kernel
{
private $environment;
private $debug;
private $bundles;

/**
* Constructor.
*
* @param string $environment
* @param bool $debug
* @param array $bundles
*/
public function __construct($environment, $debug, array $bundles = array())
{
$this->environment = $environment;
$this->debug = $debug;
$this->bundles = array();
$numBundles = count($bundles);
$numProcessedBundles = 0;
do {
foreach ($bundles as $name => $bundle) {
$parent = $bundle['parent'];
if (null !== $parent && !isset($this->bundles[$parent])) {
continue;
}
if (!isset($this->bundles[$name])) {
$parentBundle = isset($this->bundles[$parent]) ? $this->bundles[$parent] : null;
$this->bundles[$name] = new $bundle['service_class']($name, $bundle['namespace'], $bundle['class'], $bundle['path'], $parentBundle);
++$numProcessedBundles;
}
}
} while ($numProcessedBundles < $numBundles);
}

final public function getEnvironment()
{
return $this->environment;
}

final public function isDebug()
{
return $this->debug;
}

final public function getBundles()
{
return $this->bundles;
}
}
0