Файл: symfony-2.7/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php
Строк: 351
<?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 SymfonyBundleFrameworkBundle;
use SymfonyBundleFrameworkBundleDependencyInjectionCompilerAddConstraintValidatorsPass;
use SymfonyBundleFrameworkBundleDependencyInjectionCompilerAddValidatorInitializersPass;
use SymfonyBundleFrameworkBundleDependencyInjectionCompilerAddConsoleCommandPass;
use SymfonyBundleFrameworkBundleDependencyInjectionCompilerFormPass;
use SymfonyBundleFrameworkBundleDependencyInjectionCompilerTemplatingPass;
use SymfonyBundleFrameworkBundleDependencyInjectionCompilerTemplatingAssetHelperPass;
use SymfonyBundleFrameworkBundleDependencyInjectionCompilerRoutingResolverPass;
use SymfonyBundleFrameworkBundleDependencyInjectionCompilerProfilerPass;
use SymfonyBundleFrameworkBundleDependencyInjectionCompilerTranslatorPass;
use SymfonyBundleFrameworkBundleDependencyInjectionCompilerLoggingTranslatorPass;
use SymfonyBundleFrameworkBundleDependencyInjectionCompilerAddCacheWarmerPass;
use SymfonyBundleFrameworkBundleDependencyInjectionCompilerAddCacheClearerPass;
use SymfonyBundleFrameworkBundleDependencyInjectionCompilerAddExpressionLanguageProvidersPass;
use SymfonyBundleFrameworkBundleDependencyInjectionCompilerContainerBuilderDebugDumpPass;
use SymfonyBundleFrameworkBundleDependencyInjectionCompilerCompilerDebugDumpPass;
use SymfonyBundleFrameworkBundleDependencyInjectionCompilerTranslationExtractorPass;
use SymfonyBundleFrameworkBundleDependencyInjectionCompilerTranslationDumperPass;
use SymfonyBundleFrameworkBundleDependencyInjectionCompilerSerializerPass;
use SymfonyComponentDebugErrorHandler;
use SymfonyComponentDependencyInjectionContainerBuilder;
use SymfonyComponentDependencyInjectionCompilerPassConfig;
use SymfonyComponentDependencyInjectionScope;
use SymfonyComponentEventDispatcherDependencyInjectionRegisterListenersPass;
use SymfonyComponentHttpKernelDependencyInjectionFragmentRendererPass;
use SymfonyComponentHttpFoundationRequest;
use SymfonyComponentHttpKernelBundleBundle;
/**
* Bundle.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class FrameworkBundle extends Bundle
{
public function boot()
{
ErrorHandler::register(null, false)->throwAt($this->container->getParameter('debug.error_handler.throw_at'), true);
if ($trustedProxies = $this->container->getParameter('kernel.trusted_proxies')) {
Request::setTrustedProxies($trustedProxies);
}
if ($this->container->getParameter('kernel.http_method_override')) {
Request::enableHttpMethodParameterOverride();
}
if ($trustedHosts = $this->container->getParameter('kernel.trusted_hosts')) {
Request::setTrustedHosts($trustedHosts);
}
}
public function build(ContainerBuilder $container)
{
parent::build($container);
// we need to add the request scope as early as possible so that
// the compilation can find scope widening issues
$container->addScope(new Scope('request'));
$container->addCompilerPass(new RoutingResolverPass());
$container->addCompilerPass(new ProfilerPass());
// must be registered before removing private services as some might be listeners/subscribers
// but as late as possible to get resolved parameters
$container->addCompilerPass(new RegisterListenersPass(), PassConfig::TYPE_BEFORE_REMOVING);
$container->addCompilerPass(new TemplatingPass());
$container->addCompilerPass(new TemplatingAssetHelperPass());
$container->addCompilerPass(new AddConstraintValidatorsPass());
$container->addCompilerPass(new AddValidatorInitializersPass());
$container->addCompilerPass(new AddConsoleCommandPass());
$container->addCompilerPass(new FormPass());
$container->addCompilerPass(new TranslatorPass());
$container->addCompilerPass(new LoggingTranslatorPass());
$container->addCompilerPass(new AddCacheWarmerPass());
$container->addCompilerPass(new AddCacheClearerPass());
$container->addCompilerPass(new AddExpressionLanguageProvidersPass());
$container->addCompilerPass(new TranslationExtractorPass());
$container->addCompilerPass(new TranslationDumperPass());
$container->addCompilerPass(new FragmentRendererPass(), PassConfig::TYPE_AFTER_REMOVING);
$container->addCompilerPass(new SerializerPass());
if ($container->getParameter('kernel.debug')) {
$container->addCompilerPass(new ContainerBuilderDebugDumpPass(), PassConfig::TYPE_AFTER_REMOVING);
$container->addCompilerPass(new CompilerDebugDumpPass(), PassConfig::TYPE_AFTER_REMOVING);
}
}
}