Various coding standards fixes and other minor changes in response to Crell's latest patch review
parent
f954878ccc
commit
e665805cce
|
@ -9,10 +9,14 @@ use Symfony\Component\DependencyInjection\Reference;
|
|||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
|
||||
|
||||
class DrupalBundle extends Bundle
|
||||
/**
|
||||
* This is where Drupal core registers all of its services to the Dependency
|
||||
* Injection Container. Modules wishing to register services to the container
|
||||
* should extend Symfony's Bundle class directly, not this class.
|
||||
*/
|
||||
class CoreBundle extends Bundle
|
||||
{
|
||||
public function build(ContainerBuilder $container)
|
||||
{
|
||||
public function build(ContainerBuilder $container) {
|
||||
$container->register('dispatcher', 'Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher')
|
||||
->addArgument(new Reference('service_container'));
|
||||
$container->register('resolver', 'Symfony\Component\HttpKernel\Controller\ControllerResolver');
|
||||
|
@ -57,6 +61,5 @@ class DrupalBundle extends Bundle
|
|||
|
||||
// Add a compiler pass for registering event subscribers.
|
||||
$container->addCompilerPass(new RegisterKernelListenersPass(), PassConfig::TYPE_AFTER_REMOVING);
|
||||
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
namespace Drupal\Core\DependencyInjection\Compiler;
|
||||
|
||||
use ReflectionClass;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
|
||||
|
@ -25,7 +26,7 @@ class RegisterKernelListenersPass implements CompilerPassInterface
|
|||
// We must assume that the class value has been correcly filled, even if the service is created by a factory
|
||||
$class = $container->getDefinition($id)->getClass();
|
||||
|
||||
$refClass = new \ReflectionClass($class);
|
||||
$refClass = new ReflectionClass($class);
|
||||
$interface = 'Symfony\Component\EventDispatcher\EventSubscriberInterface';
|
||||
if (!$refClass->implementsInterface($interface)) {
|
||||
throw new \InvalidArgumentException(sprintf('Service "%s" must implement interface "%s".', $id, $interface));
|
||||
|
|
|
@ -18,21 +18,16 @@ use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
|
|||
*/
|
||||
class ContainerBuilder extends BaseContainerBuilder {
|
||||
|
||||
public function addCompilerPass(CompilerPassInterface $pass, $type = PassConfig::TYPE_BEFORE_OPTIMIZATION)
|
||||
{
|
||||
if (!isset($this->compiler) || null === $this->compiler) {
|
||||
$this->compiler = new Compiler();
|
||||
}
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->compiler = new Compiler();
|
||||
}
|
||||
|
||||
public function addCompilerPass(CompilerPassInterface $pass, $type = PassConfig::TYPE_BEFORE_OPTIMIZATION) {
|
||||
$this->compiler->addPass($pass, $type);
|
||||
}
|
||||
|
||||
public function compile()
|
||||
{
|
||||
if (null === $this->compiler) {
|
||||
$this->compiler = new Compiler();
|
||||
}
|
||||
|
||||
public function compile() {
|
||||
$this->compiler->compile($this);
|
||||
$this->parameterBag->resolve();
|
||||
// TODO: The line below is commented out because there is code that calls
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace Drupal\Core;
|
||||
|
||||
use Drupal\Core\DrupalBundle;
|
||||
use Drupal\Core\CoreBundle;
|
||||
use Symfony\Component\HttpKernel\Kernel;
|
||||
use Drupal\Core\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||
|
@ -18,10 +18,9 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
|||
*/
|
||||
class DrupalKernel extends Kernel {
|
||||
|
||||
public function registerBundles()
|
||||
{
|
||||
public function registerBundles() {
|
||||
$bundles = array(
|
||||
new DrupalBundle(),
|
||||
new CoreBundle(),
|
||||
);
|
||||
|
||||
// Rather than bootstrapping to a higher phase prior to booting the Kernel, which
|
||||
|
@ -47,8 +46,7 @@ class DrupalKernel extends Kernel {
|
|||
/**
|
||||
* Initializes the service container.
|
||||
*/
|
||||
protected function initializeContainer()
|
||||
{
|
||||
protected function initializeContainer() {
|
||||
$this->container = $this->buildContainer();
|
||||
$this->container->set('kernel', $this);
|
||||
drupal_container($this->container);
|
||||
|
@ -59,8 +57,7 @@ class DrupalKernel extends Kernel {
|
|||
*
|
||||
* @return ContainerBuilder The compiled service container
|
||||
*/
|
||||
protected function buildContainer()
|
||||
{
|
||||
protected function buildContainer() {
|
||||
$container = $this->getContainerBuilder();
|
||||
|
||||
if ($bootstrap_container = drupal_container()) {
|
||||
|
@ -73,19 +70,16 @@ class DrupalKernel extends Kernel {
|
|||
return $container;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets a new ContainerBuilder instance used to build the service container.
|
||||
*
|
||||
* @return ContainerBuilder
|
||||
*/
|
||||
protected function getContainerBuilder()
|
||||
{
|
||||
protected function getContainerBuilder() {
|
||||
return new ContainerBuilder(new ParameterBag($this->getKernelParameters()));
|
||||
}
|
||||
|
||||
public function registerContainerConfiguration(LoaderInterface $loader)
|
||||
{
|
||||
public function registerContainerConfiguration(LoaderInterface $loader) {
|
||||
// We have to define this method because it's not defined in the base class
|
||||
// but is part of the KernelInterface interface. However, the LoaderInterface
|
||||
// class is part of the config component, which we are not using, so this
|
||||
|
|
Loading…
Reference in New Issue