2010-02-17 13:55:05 +00:00
|
|
|
<?php
|
|
|
|
|
2011-01-15 13:29:43 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the Symfony package.
|
|
|
|
*
|
2011-03-06 11:40:06 +00:00
|
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
2011-01-15 13:29:43 +00:00
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
2010-07-09 09:05:26 +01:00
|
|
|
namespace Symfony\Bundle\FrameworkBundle;
|
2010-02-17 13:55:05 +00:00
|
|
|
|
2011-01-05 19:53:38 +00:00
|
|
|
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddConstraintValidatorsPass;
|
2011-01-19 12:43:24 +00:00
|
|
|
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddFieldFactoryGuessersPass;
|
2011-01-13 13:58:17 +00:00
|
|
|
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TemplatingPass;
|
2011-01-05 11:13:27 +00:00
|
|
|
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\RegisterKernelListenersPass;
|
2010-12-23 11:32:51 +00:00
|
|
|
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\RoutingResolverPass;
|
2010-12-23 11:48:45 +00:00
|
|
|
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ProfilerPass;
|
2011-01-16 09:17:38 +00:00
|
|
|
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddClassesToCachePass;
|
2011-01-27 13:26:49 +00:00
|
|
|
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddClassesToAutoloadMapPass;
|
2011-01-17 10:29:38 +00:00
|
|
|
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslatorPass;
|
2011-01-24 10:16:22 +00:00
|
|
|
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddCacheWarmerPass;
|
2011-03-10 15:09:40 +00:00
|
|
|
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ContainerBuilderDebugDumpPass;
|
2011-04-14 20:04:45 +01:00
|
|
|
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CompilerDebugDumpPass;
|
2010-12-20 19:56:14 +00:00
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
2011-01-16 09:17:38 +00:00
|
|
|
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
|
2011-02-13 09:33:53 +00:00
|
|
|
use Symfony\Component\DependencyInjection\Scope;
|
2011-01-18 19:18:28 +00:00
|
|
|
use Symfony\Component\HttpFoundation\File\File;
|
2010-09-15 19:49:16 +01:00
|
|
|
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
2011-01-27 13:26:49 +00:00
|
|
|
use Symfony\Component\ClassLoader\ClassCollectionLoader;
|
|
|
|
use Symfony\Component\ClassLoader\MapFileClassLoader;
|
2010-02-17 13:55:05 +00:00
|
|
|
|
|
|
|
/**
|
2010-04-07 01:51:29 +01:00
|
|
|
* Bundle.
|
2010-02-17 13:55:05 +00:00
|
|
|
*
|
2011-03-06 11:40:06 +00:00
|
|
|
* @author Fabien Potencier <fabien@symfony.com>
|
2010-02-17 13:55:05 +00:00
|
|
|
*/
|
2010-07-09 09:05:26 +01:00
|
|
|
class FrameworkBundle extends Bundle
|
2010-02-17 13:55:05 +00:00
|
|
|
{
|
2010-09-10 13:32:33 +01:00
|
|
|
/**
|
|
|
|
* Boots the Bundle.
|
|
|
|
*/
|
|
|
|
public function boot()
|
|
|
|
{
|
2011-01-27 13:07:30 +00:00
|
|
|
// load core classes
|
|
|
|
ClassCollectionLoader::load(
|
|
|
|
$this->container->getParameter('kernel.compiled_classes'),
|
|
|
|
$this->container->getParameter('kernel.cache_dir'),
|
|
|
|
'classes',
|
|
|
|
$this->container->getParameter('kernel.debug'),
|
|
|
|
true
|
|
|
|
);
|
2011-01-27 13:26:49 +00:00
|
|
|
|
2011-01-27 15:34:54 +00:00
|
|
|
if ($this->container->has('error_handler')) {
|
|
|
|
$this->container->get('error_handler');
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->container->hasParameter('document_root')) {
|
|
|
|
File::setDocumentRoot($this->container->getParameter('document_root'));
|
|
|
|
}
|
|
|
|
|
2011-01-27 13:26:49 +00:00
|
|
|
if (file_exists($this->container->getParameter('kernel.cache_dir').'/autoload.php')) {
|
|
|
|
$classloader = new MapFileClassLoader($this->container->getParameter('kernel.cache_dir').'/autoload.php');
|
|
|
|
$classloader->register(true);
|
|
|
|
}
|
2010-09-10 13:32:33 +01:00
|
|
|
}
|
2010-12-20 19:56:14 +00:00
|
|
|
|
2011-02-15 03:47:19 +00:00
|
|
|
public function build(ContainerBuilder $container)
|
2010-12-20 19:56:14 +00:00
|
|
|
{
|
2011-02-15 03:47:19 +00:00
|
|
|
parent::build($container);
|
2010-12-20 19:56:14 +00:00
|
|
|
|
2011-02-13 09:33:53 +00:00
|
|
|
$container->addScope(new Scope('request'));
|
2011-01-17 22:28:59 +00:00
|
|
|
|
2010-12-23 11:32:51 +00:00
|
|
|
$container->addCompilerPass(new RoutingResolverPass());
|
2010-12-23 11:48:45 +00:00
|
|
|
$container->addCompilerPass(new ProfilerPass());
|
2011-01-05 11:13:27 +00:00
|
|
|
$container->addCompilerPass(new RegisterKernelListenersPass());
|
2011-01-13 13:58:17 +00:00
|
|
|
$container->addCompilerPass(new TemplatingPass());
|
2011-01-05 19:53:38 +00:00
|
|
|
$container->addCompilerPass(new AddConstraintValidatorsPass());
|
2011-01-19 12:43:24 +00:00
|
|
|
$container->addCompilerPass(new AddFieldFactoryGuessersPass());
|
2011-01-16 09:17:38 +00:00
|
|
|
$container->addCompilerPass(new AddClassesToCachePass());
|
2011-01-27 13:26:49 +00:00
|
|
|
$container->addCompilerPass(new AddClassesToAutoloadMapPass());
|
2011-01-17 10:29:38 +00:00
|
|
|
$container->addCompilerPass(new TranslatorPass());
|
2011-01-24 10:16:22 +00:00
|
|
|
$container->addCompilerPass(new AddCacheWarmerPass());
|
2011-03-15 08:29:59 +00:00
|
|
|
$container->addCompilerPass(new ContainerBuilderDebugDumpPass(), PassConfig::TYPE_BEFORE_REMOVING);
|
2011-04-12 23:51:22 +01:00
|
|
|
$container->addCompilerPass(new CompilerDebugDumpPass(), PassConfig::TYPE_AFTER_REMOVING);
|
2010-12-20 19:56:14 +00:00
|
|
|
}
|
2010-02-17 13:55:05 +00:00
|
|
|
}
|