Skip to content

Commit

Permalink
modified BundleInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Aug 10, 2010
1 parent 17bc06a commit c87dd77
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 51 deletions.
9 changes: 4 additions & 5 deletions src/Symfony/Bundle/PropelBundle/PropelBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
namespace Symfony\Bundle\PropelBundle;

use Symfony\Framework\Bundle\Bundle;
use Symfony\Components\DependencyInjection\ContainerInterface;

class PropelBundle extends Bundle
{
public function boot(ContainerInterface $container)
public function boot()
{
require_once $container->getParameter('propel.path').'/runtime/lib/Propel.php';
require_once $this->container->getParameter('propel.path').'/runtime/lib/Propel.php';

if (0 === strncasecmp(PHP_SAPI, 'cli', 3)) {
set_include_path($container->getParameter('propel.phing_path').'/classes'.PATH_SEPARATOR.get_include_path());
set_include_path($this->container->getParameter('propel.phing_path').'/classes'.PATH_SEPARATOR.get_include_path());
}

$container->getPropelService();
$this->container->getPropelService();
}
}
19 changes: 13 additions & 6 deletions src/Symfony/Framework/Bundle/Bundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,33 @@
*/
abstract class Bundle implements BundleInterface
{
protected $container;
protected $name;
protected $namespacePrefix;
protected $path;
protected $reflection;

/**
* Boots the Bundle.
* Sets the Container associated with this bundle.
*
* @param ContainerInterface $container A ContainerInterface instance
*/
public function boot(ContainerInterface $container)
public function setContainer(ContainerInterface $container = null)
{
$this->container = $container;
}

/**
* Boots the Bundle.
*/
public function boot()
{
}

/**
* Shutdowns the Bundle.
*
* @param ContainerInterface $container A ContainerInterface instance
*/
public function shutdown(ContainerInterface $container)
public function shutdown()
{
}

Expand Down Expand Up @@ -111,7 +118,7 @@ public function getReflection()
* * Extensions are in the 'DependencyInjection/' sub-directory
* * Extension class names ends with 'Extension'
*
* @param ContainerBuilder A ContainerBuilder instance
* @param ContainerBuilder $container A ContainerBuilder instance
*/
public function registerExtensions(ContainerBuilder $container)
{
Expand Down
13 changes: 7 additions & 6 deletions src/Symfony/Framework/Bundle/BundleInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
namespace Symfony\Framework\Bundle;

use Symfony\Components\DependencyInjection\ContainerInterface;
use Symfony\Components\DependencyInjection\ContainerBuilder;
use Symfony\Components\DependencyInjection\ParameterBag\ParameterBagInterface;

/*
* This file is part of the Symfony framework.
Expand All @@ -24,15 +22,18 @@ interface BundleInterface
{
/**
* Boots the Bundle.
*
* @param ContainerInterface $container A ContainerInterface instance
*/
public function boot(ContainerInterface $container);
public function boot();

/**
* Shutdowns the Bundle.
*/
public function shutdown();

/**
* Sets the Container associated with this bundle.
*
* @param ContainerInterface $container A ContainerInterface instance
*/
public function shutdown(ContainerInterface $container);
public function setContainer(ContainerInterface $container);
}
25 changes: 11 additions & 14 deletions src/Symfony/Framework/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ public function isBooted()
* This method boots the bundles, which MUST set
* the DI container.
*
* @return Kernel The current Kernel instance
*
* @throws \LogicException When the Kernel is already booted
*/
public function boot()
Expand All @@ -123,19 +121,14 @@ public function boot()

$this->bundles = $this->registerBundles();
$this->bundleDirs = $this->registerBundleDirs();

// initialize the container
$this->container = $this->initializeContainer();
$this->container->set('kernel', $this);

// boot bundles
foreach ($this->bundles as $bundle) {
$bundle->boot($this->container);
$bundle->setContainer($this->container);
$bundle->boot();
}

$this->booted = true;

return $this;
}

/**
Expand All @@ -148,7 +141,8 @@ public function shutdown()
$this->booted = false;

foreach ($this->bundles as $bundle) {
$bundle->shutdown($this->container);
$bundle->shutdown();
$bundle->setContainer(null);
}

$this->container = null;
Expand Down Expand Up @@ -193,15 +187,15 @@ public function handle(Request $request = null, $type = HttpKernelInterface::MAS
}

if (null === $request) {
$request = $this->container->getRequestService();
$request = $this->container->get('request');
} else {
$this->container->set('request', $request);
}

if (HttpKernelInterface::MASTER_REQUEST === $type) {
$this->request = $request;
}

$this->container->set('request', $request);

$response = $this->container->getHttpKernelService()->handle($request, $type, $raw);

$this->container->set('request', $this->request);
Expand Down Expand Up @@ -305,7 +299,10 @@ protected function initializeContainer()

require_once $location.'.php';

return new $class();
$container = new $class();
$container->set('kernel', $this);

return $container;
}

public function getKernelParameters()
Expand Down
13 changes: 5 additions & 8 deletions src/Symfony/Framework/KernelBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Symfony\Framework\Bundle\Bundle;
use Symfony\Framework\ClassCollectionLoader;
use Symfony\Components\DependencyInjection\ContainerInterface;

/*
* This file is part of the Symfony framework.
Expand All @@ -24,18 +23,16 @@ class KernelBundle extends Bundle
{
/**
* Boots the Bundle.
*
* @param ContainerInterface $container A ContainerInterface instance
*/
public function boot(ContainerInterface $container)
public function boot()
{
if ($container->has('error_handler')) {
$container['error_handler'];
if ($this->container->has('error_handler')) {
$this->container['error_handler'];
}

// load core classes
if ($container->getParameterBag()->has('kernel.include_core_classes') && $container->getParameter('kernel.include_core_classes')) {
ClassCollectionLoader::load($container->getParameter('kernel.compiled_classes'), $container->getParameter('kernel.cache_dir'), 'classes', $container->getParameter('kernel.debug'));
if ($this->container->getParameterBag()->has('kernel.include_core_classes') && $this->container->getParameter('kernel.include_core_classes')) {
ClassCollectionLoader::load($this->container->getParameter('kernel.compiled_classes'), $this->container->getParameter('kernel.cache_dir'), 'classes', $this->container->getParameter('kernel.debug'));
}
}
}
31 changes: 19 additions & 12 deletions src/Symfony/Framework/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,25 @@

abstract class Bundle implements BundleInterface
{
protected $container;
protected $name;
protected $namespacePrefix;
protected $path;
protected $reflection;


public function boot(ContainerInterface $container)
public function setContainer(ContainerInterface $container = null)
{
$this->container = $container;
}


public function shutdown(ContainerInterface $container)
public function boot()
{
}


public function shutdown()
{
}

Expand Down Expand Up @@ -121,42 +128,42 @@ protected function initReflection()
namespace Symfony\Framework\Bundle;

use Symfony\Components\DependencyInjection\ContainerInterface;
use Symfony\Components\DependencyInjection\ContainerBuilder;
use Symfony\Components\DependencyInjection\ParameterBag\ParameterBagInterface;




interface BundleInterface
{

public function boot(ContainerInterface $container);
public function boot();


public function shutdown();


public function shutdown(ContainerInterface $container);
public function setContainer(ContainerInterface $container);
}


namespace Symfony\Framework;

use Symfony\Framework\Bundle\Bundle;
use Symfony\Framework\ClassCollectionLoader;
use Symfony\Components\DependencyInjection\ContainerInterface;




class KernelBundle extends Bundle
{

public function boot(ContainerInterface $container)
public function boot()
{
if ($container->has('error_handler')) {
$container['error_handler'];
if ($this->container->has('error_handler')) {
$this->container['error_handler'];
}

if ($container->getParameterBag()->has('kernel.include_core_classes') && $container->getParameter('kernel.include_core_classes')) {
ClassCollectionLoader::load($container->getParameter('kernel.compiled_classes'), $container->getParameter('kernel.cache_dir'), 'classes', $container->getParameter('kernel.debug'));
if ($this->container->getParameterBag()->has('kernel.include_core_classes') && $this->container->getParameter('kernel.include_core_classes')) {
ClassCollectionLoader::load($this->container->getParameter('kernel.compiled_classes'), $this->container->getParameter('kernel.cache_dir'), 'classes', $this->container->getParameter('kernel.debug'));
}
}
}
Expand Down

0 comments on commit c87dd77

Please sign in to comment.