Changeset 31898
- Timestamp:
- 01/25/11 09:45:06 (2 years ago)
- Files:
-
- branches/2.0/src/Symfony/Bundle/CompatAssetsBundle/Templating/Helper/JavascriptsHelper.php (modified) (1 diff)
- branches/2.0/src/Symfony/Bundle/CompatAssetsBundle/Templating/Helper/StylesheetsHelper.php (modified) (1 diff)
- branches/2.0/src/Symfony/Bundle/DoctrineBundle/DependencyInjection/DoctrineExtension.php (modified) (1 diff, 1 prop)
- branches/2.0/src/Symfony/Bundle/DoctrineBundle/Resources/config/orm.xml (modified) (1 diff)
- branches/2.0/src/Symfony/Bundle/DoctrineBundle/Tests/Command/InfoDoctrineCommandTest.php (modified) (1 diff)
- branches/2.0/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php (modified) (5 diffs, 1 prop)
- branches/2.0/src/Symfony/Bundle/DoctrineMigrationsBundle/Command/DoctrineCommand.php (modified) (1 diff)
- branches/2.0/src/Symfony/Bundle/DoctrineMongoDBBundle/Command/LoadDataFixturesDoctrineODMCommand.php (modified) (1 diff)
- branches/2.0/src/Symfony/Bundle/DoctrineMongoDBBundle/DependencyInjection/DoctrineMongoDBExtension.php (modified) (1 diff)
- branches/2.0/src/Symfony/Bundle/DoctrineMongoDBBundle/Resources/config/mongodb.xml (modified) (2 diffs)
- branches/2.0/src/Symfony/Bundle/DoctrineMongoDBBundle/Tests/ContainerTest.php (modified) (1 diff)
- branches/2.0/src/Symfony/Bundle/DoctrineMongoDBBundle/Tests/DependencyInjection/AbstractMongoDBExtensionTest.php (modified) (1 diff)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/Cache/Cache.php (modified) (1 diff)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/Command/CacheWarmupCommand.php (added)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/Console/Application.php (modified) (1 diff)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php (modified) (1 diff)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/Controller/ParamConverterListener.php (modified) (2 diffs)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/Debug/EventDispatcher.php (modified) (6 diffs)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddCacheWarmerPass.php (added)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/RegisterKernelListenersPass.php (modified) (1 diff)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/TemplatingPass.php (modified) (1 diff)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php (modified) (5 diffs)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/EventDispatcher.php (modified) (2 diffs)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php (modified) (2 diffs)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/RequestListener.php (modified) (2 diffs)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug.xml (modified) (1 diff)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/config/esi.xml (modified) (1 diff)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/config/param_converter.xml (modified) (1 diff)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/config/profiling.xml (modified) (1 diff)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing.xml (modified) (4 diffs)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd (modified) (4 diffs)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/config/security.xml (modified) (1 diff)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml (modified) (3 diffs)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating.xml (modified) (4 diffs)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_php.xml (added)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/config/web.xml (modified) (2 diffs)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/error.atom.twig (modified) (1 diff)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/error.rdf.twig (modified) (1 diff)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/exception.atom.twig (modified) (1 diff)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/exception.xml.twig (modified) (1 diff)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/Routing/CacheWarmer (added)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/Routing/CacheWarmer/RouterCacheWarmer.php (added)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/Routing/CachedRouter.php (added)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/Templating/CacheWarmer (added)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/Templating/CacheWarmer/TemplatePathsCacheWarmer.php (added)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/Templating/DelegatingEngine.php (modified) (1 diff)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/ActionsHelper.php (modified) (1 diff)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/Templating/Loader/CachedTemplateLocator.php (added)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php (modified) (1 diff)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php (modified) (1 diff)
- branches/2.0/src/Symfony/Bundle/TwigBundle/CacheWarmer (added)
- branches/2.0/src/Symfony/Bundle/TwigBundle/CacheWarmer/TemplateCacheCacheWarmer.php (added)
- branches/2.0/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php (modified) (1 diff)
- branches/2.0/src/Symfony/Bundle/TwigBundle/Resources/config/schema/twig-1.0.xsd (modified) (2 diffs)
- branches/2.0/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml (modified) (2 diffs)
- branches/2.0/src/Symfony/Bundle/WebProfilerBundle/Resources/config/toolbar.xml (modified) (1 diff)
- branches/2.0/src/Symfony/Bundle/WebProfilerBundle/WebDebugToolbarListener.php (modified) (2 diffs)
- branches/2.0/src/Symfony/Component/Console/Output/StreamOutput.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/DependencyInjection/Compiler/CheckDefinitionValidityPass.php (added)
- branches/2.0/src/Symfony/Component/DependencyInjection/Compiler/CheckReferenceScopePass.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/DependencyInjection/Compiler/ResolveInterfaceInjectorsPass.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/DependencyInjection/Compiler/ResolveInvalidReferencesPass.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/DependencyInjection/Compiler/ResolveReferencesToAliasesPass.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/DependencyInjection/Definition.php (modified) (4 diffs)
- branches/2.0/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php (modified) (2 diffs)
- branches/2.0/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php (modified) (2 diffs)
- branches/2.0/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php (modified) (2 diffs)
- branches/2.0/src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd (modified) (1 diff)
- branches/2.0/src/Symfony/Component/DependencyInjection/ParameterBag/FrozenParameterBag.php (modified) (3 diffs)
- branches/2.0/src/Symfony/Component/EventDispatcher/EventDispatcher.php (modified) (2 diffs)
- branches/2.0/src/Symfony/Component/HttpFoundation/FileBag.php (modified) (2 diffs)
- branches/2.0/src/Symfony/Component/HttpFoundation/Session.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/HttpKernel/Cache/EsiListener.php (modified) (3 diffs)
- branches/2.0/src/Symfony/Component/HttpKernel/CacheWarmer (added)
- branches/2.0/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmer.php (added)
- branches/2.0/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php (added)
- branches/2.0/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerInterface.php (added)
- branches/2.0/src/Symfony/Component/HttpKernel/ClassCollectionLoader.php (modified) (3 diffs)
- branches/2.0/src/Symfony/Component/HttpKernel/Debug/ExceptionListener.php (modified) (2 diffs)
- branches/2.0/src/Symfony/Component/HttpKernel/Kernel.php (modified) (6 diffs)
- branches/2.0/src/Symfony/Component/HttpKernel/Profiler/ProfilerListener.php (modified) (2 diffs)
- branches/2.0/src/Symfony/Component/HttpKernel/Resources/bin/packager.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/HttpKernel/ResponseListener.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/HttpKernel/Security/Firewall.php (modified) (2 diffs)
- branches/2.0/src/Symfony/Component/HttpKernel/bootstrap.php (modified) (5 diffs)
- branches/2.0/src/Symfony/Component/Routing/Generator/UrlGenerator.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/Routing/Matcher/ApacheUrlMatcher.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/Routing/Matcher/UrlMatcher.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/Routing/Router.php (modified) (1 diff)
- branches/2.0/tests/Symfony/Tests/Component/DependencyInjection/Compiler/IntegrationTest.php (modified) (7 diffs)
- branches/2.0/tests/Symfony/Tests/Component/DependencyInjection/DefinitionTest.php (modified) (3 diffs)
- branches/2.0/tests/Symfony/Tests/Component/HttpFoundation/FileBagTest.php (modified) (1 diff)
- branches/2.0/tests/Symfony/Tests/Component/HttpKernel/Cache/EsiListenerTest.php (modified) (3 diffs)
- branches/2.0/tests/Symfony/Tests/Component/HttpKernel/ResponseListenerTest.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/2.0/src/Symfony/Bundle/CompatAssetsBundle/Templating/Helper/JavascriptsHelper.php
r31885 r31898 84 84 85 85 /** 86 * Outputs HTML representation of the links to JavaScripts.87 *88 */89 public function output()90 {91 echo $this->render();92 }93 94 /**95 86 * Returns a string representation of this helper as HTML. 96 87 * branches/2.0/src/Symfony/Bundle/CompatAssetsBundle/Templating/Helper/StylesheetsHelper.php
r31885 r31898 84 84 85 85 /** 86 * Outputs HTML representation of the links to stylesheets.87 *88 */89 public function output()90 {91 echo $this->render();92 }93 94 /**95 86 * Returns a string representation of this helper as HTML. 96 87 * branches/2.0/src/Symfony/Bundle/DoctrineBundle/DependencyInjection/DoctrineExtension.php
- Property svn:executable set to *
r31885 r31898 282 282 } 283 283 if (isset($config['auto_generate_proxy_classes'])) { 284 $ mergedConfig['auto_generate_proxy_classes'] = $config['auto_generate_proxy_classes'];284 $defaultManagerOptions['auto_generate_proxy_classes'] = $config['auto_generate_proxy_classes']; 285 285 } 286 286 if (isset($config['auto-generate-proxy-classes'])) { 287 $ mergedConfig['auto_generate_proxy_classes'] = $config['auto-generate-proxy-classes'];287 $defaultManagerOptions['auto_generate_proxy_classes'] = $config['auto-generate-proxy-classes']; 288 288 } 289 289 } branches/2.0/src/Symfony/Bundle/DoctrineBundle/Resources/config/orm.xml
r31885 r31898 31 31 <parameter key="doctrine.orm.metadata.annotation_class">Doctrine\ORM\Mapping\Driver\AnnotationDriver</parameter> 32 32 <parameter key="doctrine.orm.metadata.annotation_reader_class">Doctrine\Common\Annotations\AnnotationReader</parameter> 33 <parameter key="doctrine.orm.metadata.annotation_default_namespace">Doctrine\ORM\Mapping\</parameter>34 33 <parameter key="doctrine.orm.metadata.xml_class">Doctrine\ORM\Mapping\Driver\XmlDriver</parameter> 35 34 <parameter key="doctrine.orm.metadata.yml_class">Doctrine\ORM\Mapping\Driver\YamlDriver</parameter> branches/2.0/src/Symfony/Bundle/DoctrineBundle/Tests/Command/InfoDoctrineCommandTest.php
r31885 r31898 24 24 $kernel = $this->getMock('Symfony\Component\HttpKernel\Kernel', array(), array(), '', false); 25 25 $kernel->expects($this->once()) 26 ->method('isBooted')27 ->will($this->returnValue( true ));28 $kernel->expects($this->once())29 26 ->method('getBundles') 30 27 ->will($this->returnValue(array())); branches/2.0/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php
- Property svn:executable set to *
r31885 r31898 134 134 $this->assertEquals('Doctrine\ORM\Mapping\Driver\AnnotationDriver', $container->getParameter('doctrine.orm.metadata.annotation_class')); 135 135 $this->assertEquals('Doctrine\Common\Annotations\AnnotationReader', $container->getParameter('doctrine.orm.metadata.annotation_reader_class')); 136 $this->assertEquals('Doctrine\ORM\Mapping\\', $container->getParameter('doctrine.orm.metadata.annotation_default_namespace'));137 136 $this->assertEquals('Doctrine\ORM\Mapping\Driver\XmlDriver', $container->getParameter('doctrine.orm.metadata.xml_class')); 138 137 $this->assertEquals('Doctrine\ORM\Mapping\Driver\YamlDriver', $container->getParameter('doctrine.orm.metadata.yml_class')); … … 426 425 } 427 426 428 public function test MultipleOrmLoadCalls()427 public function testOrmMergeConfigs() 429 428 { 430 429 $container = $this->getContainer(array('XmlBundle', 'AnnotationsBundle')); … … 433 432 $loader->dbalLoad(array(array()), $container); 434 433 $loader->ormLoad(array(array( 435 'auto_generate_proxy_ dir' => true,434 'auto_generate_proxy_classes' => true, 436 435 'mappings' => array('AnnotationsBundle' => array()) 437 436 ), 438 437 array( 439 'auto_generate_proxy_ dir' => false,438 'auto_generate_proxy_classes' => false, 440 439 'mappings' => array('XmlBundle' => array()) 441 440 )), $container); … … 452 451 453 452 $configDef = $container->getDefinition('doctrine.orm.default_configuration'); 454 $this->assertDICDefinitionMethodCallOnce($configDef, 'setAutoGenerateProxyClasses', array( false));453 $this->assertDICDefinitionMethodCallOnce($configDef, 'setAutoGenerateProxyClasses', array( false )); 455 454 } 456 455 … … 515 514 516 515 $configDefinition = $container->getDefinition('doctrine.orm.default_configuration'); 517 $this->assertDICDefinitionMethodCallOnce($configDefinition, 'setAutoGenerateProxyClasses', array( false));516 $this->assertDICDefinitionMethodCallOnce($configDefinition, 'setAutoGenerateProxyClasses', array(true)); 518 517 } 519 518 branches/2.0/src/Symfony/Bundle/DoctrineMigrationsBundle/Command/DoctrineCommand.php
r31885 r31898 28 28 $configuration->setMigrationsNamespace($bundle.'\DoctrineMigrations'); 29 29 30 $bundle = $ this->application->getKernel()->getBundle($input->getArgument('bundle'));30 $bundle = $application->getKernel()->getBundle($bundle); 31 31 $dir = $bundle->getPath().'/DoctrineMigrations'; 32 32 33 33 $configuration->setMigrationsDirectory($dir); 34 34 $configuration->registerMigrationsFromDirectory($dir); 35 $configuration->setName($bundle .' Migrations');35 $configuration->setName($bundle->getName().' Migrations'); 36 36 $configuration->setMigrationsTableName(Inflector::tableize($bundle->getName()).'_migration_versions'); 37 37 } branches/2.0/src/Symfony/Bundle/DoctrineMongoDBBundle/Command/LoadDataFixturesDoctrineODMCommand.php
r31885 r31898 73 73 } 74 74 75 $paths = array_filter($paths, 'is_dir'); 76 75 77 $loader = new \Doctrine\Common\DataFixtures\Loader(); 76 78 foreach ($paths as $path) { branches/2.0/src/Symfony/Bundle/DoctrineMongoDBBundle/DependencyInjection/DoctrineMongoDBExtension.php
r31885 r31898 73 73 'default_document_manager', 74 74 'default_connection', 75 'cache_driver',76 75 'metadata_cache_driver', 77 76 'proxy_namespace', branches/2.0/src/Symfony/Bundle/DoctrineMongoDBBundle/Resources/config/mongodb.xml
r31885 r31898 23 23 24 24 <!-- hydrators --> 25 <parameter key="doctrine.odm.mongodb.hydrator_namespace"> Proxies</parameter>25 <parameter key="doctrine.odm.mongodb.hydrator_namespace">Hydrators</parameter> 26 26 <parameter key="doctrine.odm.mongodb.hydrator_dir">%kernel.cache_dir%/doctrine/odm/mongodb/Hydrators</parameter> 27 27 <parameter key="doctrine.odm.mongodb.auto_generate_hydrator_classes">false</parameter> … … 40 40 <parameter key="doctrine.odm.mongodb.metadata.annotation_class">Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver</parameter> 41 41 <parameter key="doctrine.odm.mongodb.metadata.annotation_reader_class">Doctrine\Common\Annotations\AnnotationReader</parameter> 42 <parameter key="doctrine.odm.mongodb.metadata.annotation_default_namespace">Doctrine\ODM\MongoDB\Mapping\</parameter>43 42 <parameter key="doctrine.odm.mongodb.metadata.xml_class">Doctrine\ODM\MongoDB\Mapping\Driver\XmlDriver</parameter> 44 43 <parameter key="doctrine.odm.mongodb.metadata.yml_class">Doctrine\ODM\MongoDB\Mapping\Driver\YamlDriver</parameter> branches/2.0/src/Symfony/Bundle/DoctrineMongoDBBundle/Tests/ContainerTest.php
r31885 r31898 52 52 $this->assertInstanceOf('Doctrine\Common\Cache\ArrayCache', $container->get('doctrine.odm.mongodb.cache')); 53 53 $this->assertInstanceOf('Doctrine\ODM\MongoDB\DocumentManager', $container->get('doctrine.odm.mongodb.document_manager')); 54 $this->assertInstanceof('Doctrine\Common\Annotations\AnnotationReader', $container->get('doctrine.odm.mongodb.metadata.annotation_reader'));55 54 $this->assertInstanceof('Doctrine\Common\EventManager', $container->get('doctrine.odm.mongodb.event_manager')); 56 55 } branches/2.0/src/Symfony/Bundle/DoctrineMongoDBBundle/Tests/DependencyInjection/AbstractMongoDBExtensionTest.php
r31885 r31898 46 46 $this->assertEquals('Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver', $container->getParameter('doctrine.odm.mongodb.metadata.annotation_class')); 47 47 $this->assertEquals('Doctrine\Common\Annotations\AnnotationReader', $container->getParameter('doctrine.odm.mongodb.metadata.annotation_reader_class')); 48 $this->assertEquals('Doctrine\ODM\MongoDB\Mapping\\', $container->getParameter('doctrine.odm.mongodb.metadata.annotation_default_namespace'));49 48 $this->assertEquals('Doctrine\ODM\MongoDB\Mapping\Driver\XmlDriver', $container->getParameter('doctrine.odm.mongodb.metadata.xml_class')); 50 49 $this->assertEquals('Doctrine\ODM\MongoDB\Mapping\Driver\YamlDriver', $container->getParameter('doctrine.odm.mongodb.metadata.yml_class')); branches/2.0/src/Symfony/Bundle/FrameworkBundle/Cache/Cache.php
r31836 r31898 49 49 protected function forward(Request $request, $raw = false, Response $entry = null) 50 50 { 51 if (!$this->kernel->isBooted()) { 52 $this->kernel->boot(); 53 } 51 $this->kernel->boot(); 54 52 $this->kernel->getContainer()->set('cache', $this); 55 53 $this->kernel->getContainer()->set('esi', $this->esi); branches/2.0/src/Symfony/Bundle/FrameworkBundle/Console/Application.php
r31885 r31898 38 38 $this->definition->addOption(new InputOption('--shell', '-s', InputOption::VALUE_NONE, 'Launch the shell.')); 39 39 40 if (!$this->kernel->isBooted()) { 41 $this->kernel->boot(); 42 } 40 $this->kernel->boot(); 43 41 44 42 $this->registerCommands(); branches/2.0/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php
r31885 r31898 70 70 public function forward($controller, array $path = array(), array $query = array()) 71 71 { 72 return $this->container->get(' controller_resolver')->forward($controller, $path, $query);72 return $this->container->get('http_kernel')->forward($controller, $path, $query); 73 73 } 74 74 branches/2.0/src/Symfony/Bundle/FrameworkBundle/Controller/ParamConverterListener.php
r31885 r31898 24 24 * (Typehinted). 25 25 * 26 * The filterController method must be connected to the core.controller event. 27 * 26 28 * @author Fabien Potencier <fabien.potencier@symfony-project.org> 27 29 * @author Henrik Bjornskov <hb@peytz.dk> … … 40 42 { 41 43 $this->manager = $manager; 42 }43 44 /**45 * @param EventDispatcher $dispatcher46 * @param integer $priority = 047 */48 public function register(EventDispatcher $dispatcher, $priority = 0)49 {50 $dispatcher->connect('core.controller', array($this, 'filterController'), $priority);51 44 } 52 45 branches/2.0/src/Symfony/Bundle/FrameworkBundle/Debug/EventDispatcher.php
r31885 r31898 17 17 use Symfony\Component\HttpKernel\Log\LoggerInterface; 18 18 use Symfony\Component\HttpKernel\Debug\EventDispatcherTraceableInterface; 19 use Symfony\Component\DependencyInjection\ContainerInterface; 19 20 20 21 /** … … 31 32 * Constructor. 32 33 * 33 * @param LoggerInterface $logger A LoggerInterface instance 34 * @param ContainerInterface $container A ContainerInterface instance 35 * @param LoggerInterface $logger A LoggerInterface instance 34 36 */ 35 public function __construct( LoggerInterface $logger = null)37 public function __construct(ContainerInterface $container, LoggerInterface $logger = null) 36 38 { 39 parent::__construct($container); 40 37 41 $this->logger = $logger; 38 42 $this->called = array(); … … 45 49 { 46 50 foreach ($this->getListeners($event->getName()) as $listener) { 51 if (is_array($listener) && is_string($listener[0])) { 52 $listener[0] = $this->container->get($listener[0]); 53 } 54 47 55 $this->addCall($event, $listener, 'notify'); 48 56 … … 59 67 { 60 68 foreach ($this->getListeners($event->getName()) as $i => $listener) { 69 if (is_array($listener) && is_string($listener[0])) { 70 $listener[0] = $this->container->get($listener[0]); 71 } 72 61 73 $this->addCall($event, $listener, 'notifyUntil'); 62 74 … … 85 97 { 86 98 foreach ($this->getListeners($event->getName()) as $listener) { 99 if (is_array($listener) && is_string($listener[0])) { 100 $listener[0] = $this->container->get($listener[0]); 101 } 102 87 103 $this->addCall($event, $listener, 'filter'); 88 104 … … 112 128 foreach (array_keys($this->listeners) as $name) { 113 129 foreach ($this->getListeners($name) as $listener) { 130 if (is_array($listener) && is_string($listener[0])) { 131 $listener[0] = $this->container->get($listener[0]); 132 } 133 114 134 $listener = $this->listenerToString($listener); 115 135 branches/2.0/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/RegisterKernelListenersPass.php
r31885 r31898 25 25 26 26 $listeners = array(); 27 foreach ($container->findTaggedServiceIds('kernel.listener') as $id => $attributes) { 28 $priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0; 27 foreach ($container->findTaggedServiceIds('kernel.listener') as $id => $events) { 28 foreach ($events as $event) { 29 $priority = isset($event['priority']) ? $event['priority'] : 0; 30 if (!isset($event['event'])) { 31 throw new \InvalidArgumentException(sprintf('Service "%s" must define the "event" attribute on "kernel.listener" tags.', $id)); 32 } 33 if (!isset($event['method'])) { 34 throw new \InvalidArgumentException(sprintf('Service "%s" must define the "method" attribute on "kernel.listener" tags.', $id)); 35 } 29 36 30 if (!isset($listeners[$priority])) { 31 $listeners[$priority] = array(); 37 if (!isset($listeners[$event['event']][$priority])) { 38 if (!isset($listeners[$event['event']])) { 39 $listeners[$event['event']] = array(); 40 } 41 $listeners[$event['event']][$priority] = array(); 42 } 43 44 $listeners[$event['event']][$priority][] = array($id, $event['method']); 32 45 } 33 34 $listeners[$priority][] = new Reference($id);35 46 } 36 47 branches/2.0/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/TemplatingPass.php
r31885 r31898 32 32 } 33 33 34 $definition = $container->getDefinition('templating.engine.php');35 $arguments = $definition->getArguments();36 $definition->setArguments($arguments);37 38 34 if (count($helpers) > 0) { 35 $definition = $container->getDefinition('templating.engine.php'); 39 36 $definition->addMethodCall('setHelpers', array($helpers)); 40 37 } 41 38 } 42 43 if ($container->hasDefinition('templating.engine.delegating')) {44 $queue = new \SplPriorityQueue();45 $order = PHP_INT_MAX;46 foreach ($container->findTaggedServiceIds('templating.engine') as $id => $attributes) {47 $queue->insert($id, array(isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0, --$order));48 }49 50 $engines = array();51 foreach ($queue as $engine) {52 $engines[] = $engine;53 }54 55 $container->getDefinition('templating.engine.delegating')->addMethodCall('setEngineIds', array($engines));56 }57 39 } 58 40 } branches/2.0/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
r31885 r31898 158 158 } 159 159 160 if (isset($config['cache-warmer'])) { 161 $config['cache_warmer'] = $config['cache-warmer']; 162 } 163 164 $warmer = isset($config['cache_warmer']) ? $config['cache_warmer'] : !$container->getParameter('kernel.debug'); 165 $container->setParameter('kernel.cache_warmup', $warmer); 166 160 167 $this->addClassesToCompile(array( 161 168 'Symfony\\Component\\HttpFoundation\\ParameterBag', … … 206 213 $config = isset($config['templating']) ? $config['templating'] : array(); 207 214 208 if (!$container->hasDefinition('templating ')) {215 if (!$container->hasDefinition('templating.locator')) { 209 216 $loader = new XmlFileLoader($container, __DIR__.'/../Resources/config'); 210 217 $loader->load('templating.xml'); 218 $loader->load('templating_php.xml'); 211 219 212 220 if ($container->getParameter('kernel.debug')) { … … 229 237 if (array_key_exists('assets_base_urls', $config)) { 230 238 $container->setParameter('templating.assets.base_urls', $config['assets_base_urls']); 231 }232 233 // path for the filesystem loader234 if (isset($config['path'])) {235 $container->setParameter('templating.loader.filesystem.path', $config['path']);236 239 } 237 240 … … 261 264 } 262 265 263 // compilation 266 if (isset($config['cache-warmer'])) { 267 $config['cache_warmer'] = $config['cache-warmer']; 268 } 269 270 if (isset($config['cache_warmer']) && $config['cache_warmer']) { 271 $container->getDefinition('templating.cache_warmer.template_paths')->addTag('kernel.cache_warmer'); 272 $container->setAlias('templating.locator', 'templating.locator.cached'); 273 } 274 275 // engines 276 if (!$engines = $this->normalizeConfig($config, 'engine')) { 277 throw new \LogicException('You must register at least one templating engine.'); 278 } 279 280 foreach ($engines as $i => $engine) { 281 $engines[$i] = new Reference('templating.engine.'.(is_array($engine) ? $engine['id'] : $engine)); 282 } 283 284 if (1 === count($engines)) { 285 $container->setAlias('templating', (string) $engines[0]); 286 } else { 287 $def = $container->getDefinition('templating.engine.delegating'); 288 $def->setArgument(1, $engines); 289 290 $container->setAlias('templating', 'templating.engine.delegating'); 291 } 292 264 293 $this->addClassesToCompile(array( 265 'Symfony\\Component\\Templating\\DelegatingEngine',266 294 'Symfony\\Bundle\\FrameworkBundle\\Templating\\EngineInterface', 267 295 'Symfony\\Component\\Templating\\EngineInterface', 296 'Symfony\\Bundle\\FrameworkBundle\\Templating\\Loader\\TemplateLocatorInterface', 297 $container->findDefinition('templating.locator')->getClass(), 268 298 )); 269 299 } … … 436 466 $container->setParameter('routing.resource', $config['router']['resource']); 437 467 468 if (isset($config['router']['cache-warmer'])) { 469 $config['router']['cache_warmer'] = $config['router']['cache-warmer']; 470 } 471 472 if (isset($config['router']['cache_warmer']) && $config['router']['cache_warmer']) { 473 $container->getDefinition('router.cache_warmer')->addTag('kernel.cache_warmer'); 474 $container->setAlias('router', 'router.cached'); 475 } 476 438 477 $this->addClassesToCompile(array( 439 478 'Symfony\\Component\\Routing\\RouterInterface', 440 'Symfony\\Component\\Routing\\Router',441 479 'Symfony\\Component\\Routing\\Matcher\\UrlMatcherInterface', 442 480 'Symfony\\Component\\Routing\\Matcher\\UrlMatcher', 443 481 'Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface', 444 482 'Symfony\\Component\\Routing\\Generator\\UrlGenerator', 445 'Symfony\\Component\\Routing\\Loader\\LoaderInterface', 446 'Symfony\\Bundle\\FrameworkBundle\\Routing\\LazyLoader', 483 $container->findDefinition('router')->getClass() 447 484 )); 448 485 } branches/2.0/src/Symfony/Bundle/FrameworkBundle/EventDispatcher.php
r31885 r31898 13 13 14 14 use Symfony\Component\EventDispatcher\EventDispatcher as BaseEventDispatcher; 15 use Symfony\Component\DependencyInjection\ContainerInterface; 16 use Symfony\Component\EventDispatcher\Event; 15 17 16 18 /** … … 21 23 class EventDispatcher extends BaseEventDispatcher 22 24 { 23 public function registerKernelListeners(array $kernelListeners) 25 protected $container; 26 27 /** 28 * Constructor. 29 * 30 * @param ContainerInterface $container A ContainerInterface instance 31 */ 32 public function __construct(ContainerInterface $container) 24 33 { 25 foreach ($kernelListeners as $priority => $listeners) { 26 foreach ($listeners as $listener) { 27 $listener->register($this, $priority); 34 $this->container = $container; 35 } 36 37 public function registerKernelListeners(array $listeners) 38 { 39 $this->listeners = $listeners; 40 } 41 42 /** 43 * {@inheritdoc} 44 */ 45 public function notify(Event $event) 46 { 47 foreach ($this->getListeners($event->getName()) as $listener) { 48 if (is_array($listener) && is_string($listener[0])) { 49 $listener[0] = $this->container->get($listener[0]); 50 } 51 call_user_func($listener, $event); 52 } 53 54 return $event; 55 } 56 57 /** 58 * {@inheritdoc} 59 */ 60 public function notifyUntil(Event $event) 61 { 62 foreach ($this->getListeners($event->getName()) as $listener) { 63 if (is_array($listener) && is_string($listener[0])) { 64 $listener[0] = $this->container->get($listener[0]); 65 } 66 if (call_user_func($listener, $event)) { 67 $event->setProcessed(true); 68 break; 28 69 } 29 70 } 71 72 return $event; 73 } 74 75 /** 76 * {@inheritdoc} 77 */ 78 public function filter(Event $event, $value) 79 { 80 foreach ($this->getListeners($event->getName()) as $listener) { 81 if (is_array($listener) && is_string($listener[0])) { 82 $listener[0] = $this->container->get($listener[0]); 83 } 84 $value = call_user_func($listener, $event, $value); 85 } 86 87 $event->setReturnValue($value); 88 89 return $event; 30 90 } 31 91 } branches/2.0/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php
r31885 r31898 22 22 use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddClassesToCachePass; 23 23 use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslatorPass; 24 use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddCacheWarmerPass; 24 25 use Symfony\Component\DependencyInjection\ContainerBuilder; 25 26 use Symfony\Component\DependencyInjection\Compiler\PassConfig; … … 83 84 $container->addCompilerPass(new AddClassesToCachePass()); 84 85 $container->addCompilerPass(new TranslatorPass()); 86 $container->addCompilerPass(new AddCacheWarmerPass()); 85 87 } 86 88 branches/2.0/src/Symfony/Bundle/FrameworkBundle/RequestListener.php
r31885 r31898 22 22 * RequestListener. 23 23 * 24 * The handle method must be connected to the core.request event. 25 * 24 26 * @author Fabien Potencier <fabien.potencier@symfony-project.com> 25 27 */ … … 35 37 $this->router = $router; 36 38 $this->logger = $logger; 37 }38 39 /**40 * Registers a core.request listener.41 *42 * @param EventDispatcher $dispatcher An EventDispatcher instance43 * @param integer $priority The priority44 */45 public function register(EventDispatcher $dispatcher, $priority = 0)46 {47 $dispatcher->connect('core.request', array($this, 'handle'), $priority);48 39 } 49 40 branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug.xml
r31780 r31898 11 11 <services> 12 12 <service id="debug.event_dispatcher" class="%debug.event_dispatcher.class%"> 13 <argument type="service" id="service_container" /> 13 14 <argument type="service" id="logger" on-invalid="null" /> 14 15 </service> branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/config/esi.xml
r31885 r31898 13 13 <service id="esi" class="%esi.class%" public="false" /> 14 14 15 <service id="esi_listener" class="%esi_listener.class%" public="false">16 <tag name="kernel.listener" />15 <service id="esi_listener" class="%esi_listener.class%"> 16 <tag name="kernel.listener" event="core.response" method="filter" /> 17 17 <argument type="service" id="esi" on-invalid="ignore" /> 18 18 </service> branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/config/param_converter.xml
r31780 r31898 15 15 16 16 <!-- ParamConverterListener --> 17 <service id="request.param_converter.listener" class="%request.param_converter.listener.class%" public="false">18 <tag name="kernel.listener" />17 <service id="request.param_converter.listener" class="%request.param_converter.listener.class%"> 18 <tag name="kernel.listener" event="core.controller" method="filterController" /> 19 19 <argument type="service" id="request.param_converter.manager" /> 20 20 </service> branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/config/profiling.xml
r31780 r31898 25 25 </service> 26 26 27 <service id="profiler_listener" class="%profiler_listener.class%" public="false"> 28 <tag name="kernel.listener" /> 27 <service id="profiler_listener" class="%profiler_listener.class%"> 28 <tag name="kernel.listener" event="core.response" method="handleResponse" /> 29 <tag name="kernel.listener" event="core.exception" method="handleException" /> 29 30 <argument type="service" id="profiler" /> 30 31 <argument type="service" id="profiler.request_matcher" on-invalid="null" /> branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing.xml
r31885 r31898 7 7 <parameters> 8 8 <parameter key="router.class">Symfony\Component\Routing\Router</parameter> 9 <parameter key="router.cached.class">Symfony\Bundle\FrameworkBundle\Routing\CachedRouter</parameter> 9 10 <parameter key="routing.loader.class">Symfony\Bundle\FrameworkBundle\Routing\DelegatingLoader</parameter> 10 11 <parameter key="routing.file_locator.class">Symfony\Bundle\FrameworkBundle\Routing\FileLocator</parameter> … … 19 20 <parameter key="router.options.matcher_base_class">Symfony\Component\Routing\Matcher\UrlMatcher</parameter> 20 21 <parameter key="router.options.matcher_dumper_class">Symfony\Component\Routing\Matcher\Dumper\PhpMatcherDumper</parameter> 22 <parameter key="router.cache_warmer.class">Symfony\Bundle\FrameworkBundle\Routing\CacheWarmer\RouterCacheWarmer</parameter> 21 23 </parameters> 22 24 … … 54 56 </service> 55 57 56 <service id="router " class="%router.class%">58 <service id="router.real" class="%router.class%"> 57 59 <argument type="service" id="routing.loader" /> 58 60 <argument>%routing.resource%</argument> … … 70 72 </argument> 71 73 </service> 74 75 <service id="router" alias="router.real" /> 76 77 <service id="router.cached" class="%router.cached.class%"> 78 <argument>%kernel.cache_dir%</argument> 79 <argument key="matcher_cache_class">%kernel.name%_%kernel.environment%UrlMatcher</argument> 80 <argument key="generator_cache_class">%kernel.name%_%kernel.environment%UrlGenerator</argument> 81 </service> 82 83 <service id="router.cache_warmer" class="%router.cache_warmer.class%" public="false"> 84 <tag name="kernel.cache_warmer" /> 85 <argument type="service" id="router.real" /> 86 </service> 72 87 </services> 73 88 </container> branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd
r31885 r31898 24 24 <xsd:attribute name="charset" type="xsd:string" /> 25 25 <xsd:attribute name="error-handler" type="xsd:string" /> 26 <xsd:attribute name="cache-warmer" type="cache_warmer" /> 26 27 </xsd:complexType> 28 29 <xsd:simpleType name="cache_warmer"> 30 <xsd:restriction base="xsd:string"> 31 <xsd:enumeration value="false" /> 32 <xsd:enumeration value="true" /> 33 <xsd:enumeration value="full" /> 34 </xsd:restriction> 35 </xsd:simpleType> 27 36 28 37 <xsd:complexType name="profiler"> … … 41 50 <xsd:attribute name="resource" type="xsd:string" /> 42 51 <xsd:attribute name="type" type="xsd:string" /> 52 <xsd:attribute name="cache-warmer" type="cache_warmer" /> 43 53 </xsd:complexType> 44 54 … … 64 74 65 75 <xsd:complexType name="templating"> 66 <xsd:choice minOccurs="0" maxOccurs="unbounded"> 67 <xsd:element name="loader" type="xsd:string" /> 68 </xsd:choice> 76 <xsd:sequence> 77 <xsd:element name="loader" type="xsd:string" minOccurs="0" maxOccurs="unbounded" /> 78 <xsd:element name="engine" type="templating_engine" minOccurs="1" maxOccurs="unbounded" /> 79 </xsd:sequence> 69 80 70 81 <xsd:attribute name="assets-version" type="xsd:string" /> 71 82 <xsd:attribute name="assets-base-urls" type="xsd:string" /> 72 <xsd:attribute name="path" type="xsd:string" />73 83 <xsd:attribute name="cache" type="xsd:string" /> 84 <xsd:attribute name="cache-warmer" type="cache_warmer" /> 74 85 </xsd:complexType> 75 86 … … 90 101 <xsd:attribute name="enabled" type="xsd:boolean" /> 91 102 </xsd:complexType> 103 104 <xsd:complexType name="templating_engine"> 105 <xsd:attribute name="id" type="xsd:string" /> 106 </xsd:complexType> 92 107 </xsd:schema> branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/config/security.xml
r31885 r31898 155 155 </service> 156 156 157 <service id="security.firewall" class="%security.firewall.class%" public="false">158 <tag name="kernel.listener" priority="-128" />157 <service id="security.firewall" class="%security.firewall.class%"> 158 <tag name="kernel.listener" event="core.request" method="handle" priority="-128" /> 159 159 <argument type="service" id="security.firewall.map" /> 160 <argument type="service" id="event_dispatcher" /> 160 161 </service> 162 161 163 <service id="security.firewall.map" class="%security.firewall.map.class%" public="false"> 162 164 <argument type="service" id="service_container" /> 163 165 <argument type="collection" /> 164 166 </service> 165 167 166 168 <service id="security.context_listener" class="%security.context_listener.class%" public="false"> 167 169 <argument type="service" id="security.context" /> branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml
r31885 r31898 12 12 <parameter key="error_handler.level">null</parameter> 13 13 <parameter key="filesystem.class">Symfony\Bundle\FrameworkBundle\Util\Filesystem</parameter> 14 <parameter key="cache_warmer.class">Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate</parameter> 14 15 </parameters> 15 16 16 17 <services> 17 18 <service id="event_dispatcher" class="%event_dispatcher.class%"> 19 <argument type="service" id="service_container" /> 18 20 </service> 19 21 … … 28 30 </service> 29 31 32 <service id="cache_warmer" class="%cache_warmer.class%"> 33 <argument type="collection" /> 34 </service> 35 30 36 <!-- 31 37 If you want to change the Request class, modify the code in … … 35 41 It is used to check references scope. 36 42 --> 37 <service id="request" scope="request" />43 <service id="request" scope="request" synthetic="true" /> 38 44 39 45 <service id="response" class="%response.class%" scope="prototype"> branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating.xml
r31885 r31898 7 7 <parameters> 8 8 <parameter key="templating.engine.delegating.class">Symfony\Bundle\FrameworkBundle\Templating\DelegatingEngine</parameter> 9 <parameter key="templating.engine.php.class">Symfony\Bundle\FrameworkBundle\Templating\PhpEngine</parameter>10 9 <parameter key="templating.name_parser.class">Symfony\Bundle\FrameworkBundle\Templating\Loader\TemplateNameParser</parameter> 10 <parameter key="templating.cache_warmer.template_paths.class">Symfony\Bundle\FrameworkBundle\Templating\CacheWarmer\TemplatePathsCacheWarmer</parameter> 11 11 <parameter key="templating.locator.class">Symfony\Bundle\FrameworkBundle\Templating\Loader\TemplateLocator</parameter> 12 <parameter key="templating.locator.cached.class">Symfony\Bundle\FrameworkBundle\Templating\Loader\CachedTemplateLocator</parameter> 12 13 <parameter key="templating.loader.filesystem.class">Symfony\Bundle\FrameworkBundle\Templating\Loader\FilesystemLoader</parameter> 13 14 <parameter key="templating.loader.cache.class">Symfony\Component\Templating\Loader\CacheLoader</parameter> 14 15 <parameter key="templating.loader.chain.class">Symfony\Component\Templating\Loader\ChainLoader</parameter> 15 <parameter key="templating.helper.slots.class">Symfony\Component\Templating\Helper\SlotsHelper</parameter>16 <parameter key="templating.helper.assets.class">Symfony\Bundle\FrameworkBundle\Templating\Helper\AssetsHelper</parameter>17 <parameter key="templating.helper.actions.class">Symfony\Bundle\FrameworkBundle\Templating\Helper\ActionsHelper</parameter>18 <parameter key="templating.helper.router.class">Symfony\Bundle\FrameworkBundle\Templating\Helper\RouterHelper</parameter>19 <parameter key="templating.helper.request.class">Symfony\Bundle\FrameworkBundle\Templating\Helper\RequestHelper</parameter>20 <parameter key="templating.helper.session.class">Symfony\Bundle\FrameworkBundle\Templating\Helper\SessionHelper</parameter>21 <parameter key="templating.helper.code.class">Symfony\Bundle\FrameworkBundle\Templating\Helper\CodeHelper</parameter>22 <parameter key="templating.helper.translator.class">Symfony\Bundle\FrameworkBundle\Templating\Helper\TranslatorHelper</parameter>23 <parameter key="templating.helper.security.class">Symfony\Bundle\FrameworkBundle\Templating\Helper\SecurityHelper</parameter>24 <parameter key="templating.helper.form.class">Symfony\Bundle\FrameworkBundle\Templating\Helper\FormHelper</parameter>25 16 <parameter key="templating.assets.version">null</parameter> 26 17 <parameter key="templating.assets.base_urls" type="collection"></parameter> 27 <parameter key="templating.renderer.php.class">Symfony\Component\Templating\Renderer\PhpRenderer</parameter>28 18 <parameter key="debug.file_link_format">null</parameter> 29 19 </parameters> … … 32 22 <service id="templating.engine.delegating" class="%templating.engine.delegating.class%" public="false"> 33 23 <argument type="service" id="service_container" /> 34 </service> 35 36 <service id="templating.engine.php" class="%templating.engine.php.class%"> 37 <tag name="templating.engine" priority="128" /> 38 <argument type="service" id="service_container" /> 39 <argument type="service" id="templating.loader" /> 40 <call method="setCharset"><argument>%kernel.charset%</argument></call> 24 <argument type="collection" /> 41 25 </service> 42 26 … … 49 33 <argument type="service" id="templating.name_parser" /> 50 34 <argument>%kernel.root_dir%</argument> 35 </service> 36 37 <service id="templating.locator.cached" class="%templating.locator.cached.class%" public="false"> 38 <argument>%kernel.cache_dir%</argument> 39 </service> 40 41 <service id="templating.cache_warmer.template_paths" class="%templating.cache_warmer.template_paths.class%" public="false"> 42 <argument type="service" id="kernel" /> 43 <argument>%kernel.root_dir%/views</argument> 51 44 </service> 52 45 … … 65 58 </service> 66 59 67 <service id="templating.helper.slots" class="%templating.helper.slots.class%">68 <tag name="templating.helper" alias="slots" />69 </service>70 71 <service id="templating.helper.assets" class="%templating.helper.assets.class%">72 <tag name="templating.helper" alias="assets" />73 <argument type="service" id="request" strict="false" />74 <argument>%templating.assets.base_urls%</argument>75 <argument>%templating.assets.version%</argument>76 </service>77 78 <service id="templating.helper.request" class="%templating.helper.request.class%">79 <tag name="templating.helper" alias="request" />80 <argument type="service" id="request" strict="false" />81 </service>82 83 <service id="templating.helper.session" class="%templating.helper.session.class%">84 <tag name="templating.helper" alias="session" />85 <argument type="service" id="request" strict="false" />86 </service>87 88 <service id="templating.helper.router" class="%templating.helper.router.class%">89 <tag name="templating.helper" alias="router" />90 <argument type="service" id="router" />91 </service>92 93 <service id="templating.helper.actions" class="%templating.helper.actions.class%">94 <tag name="templating.helper" alias="actions" />95 <argument type="service" id="http_kernel" />96 </service>97 98 <service id="templating.helper.code" class="%templating.helper.code.class%">99 <tag name="templating.helper" alias="code" />100 <argument>%debug.file_link_format%</argument>101 <argument>%kernel.root_dir%</argument>102 </service>103 104 <service id="templating.helper.translator" class="%templating.helper.translator.class%">105 <tag name="templating.helper" alias="translator" />106 <argument type="service" id="translator" />107 </service>108 109 <service id="templating.helper.security" class="%templating.helper.security.class%">110 <tag name="templating.helper" alias="security" />111 <argument type="service" id="security.context" on-invalid="ignore" />112 </service>113 114 <service id="templating.helper.form" class="%templating.helper.form.class%">115 <tag name="templating.helper" alias="form" />116 <argument type="service" id="templating" />117 </service>118 119 60 <service id="templating.loader" alias="templating.loader.filesystem" /> 120 121 <service id="templating" alias="templating.engine.delegating" />122 61 </services> 123 62 </container> branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/config/web.xml
r31885 r31898 26 26 </service> 27 27 28 <service id="request_listener" class="%request_listener.class%" public="false">29 <tag name="kernel.listener" />28 <service id="request_listener" class="%request_listener.class%"> 29 <tag name="kernel.listener" event="core.request" method="handle" /> 30 30 <argument type="service" id="service_container" /> 31 31 <argument type="service" id="router" /> … … 33 33 </service> 34 34 35 <service id="response_listener" class="%response_listener.class%" public="false">36 <tag name="kernel.listener" />35 <service id="response_listener" class="%response_listener.class%"> 36 <tag name="kernel.listener" event="core.response" method="filter" /> 37 37 </service> 38 38 39 <service id="exception_listener" class="%exception_listener.class%" public="false">40 <tag name="kernel.listener" priority="-128" />39 <service id="exception_listener" class="%exception_listener.class%"> 40 <tag name="kernel.listener" event="core.exception" method="handle" priority="-128" /> 41 41 <argument>%exception_listener.controller%</argument> 42 42 <argument type="service" id="logger" on-invalid="null" /> branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/error.atom.twig
r31885 r31898 1 {% include 'FrameworkBundle:Exception:error. twig.xml' with { 'exception': exception } %}1 {% include 'FrameworkBundle:Exception:error.xml.twig' with { 'exception': exception } %} branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/error.rdf.twig
r31885 r31898 1 {% include 'FrameworkBundle:Exception:error. twig.xml' with { 'exception': exception } %}1 {% include 'FrameworkBundle:Exception:error.xml.twig' with { 'exception': exception } %} branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/exception.atom.twig
r31885 r31898 1 {% include 'FrameworkBundle:Exception:exception. twig.xml' with { 'exception': exception } %}1 {% include 'FrameworkBundle:Exception:exception.xml.twig' with { 'exception': exception } %} branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/exception.xml.twig
r31885 r31898 4 4 {% for e in exception.toarray %} 5 5 <exception class="{{ e.class }}" message="{{ e.message }}"> 6 {% include 'FrameworkBundle:Exception:traces. twig.xml' with { 'exception': e } only %}6 {% include 'FrameworkBundle:Exception:traces.xml.twig' with { 'exception': e } only %} 7 7 </exception> 8 8 {% endfor %} branches/2.0/src/Symfony/Bundle/FrameworkBundle/Templating/DelegatingEngine.php
r31885 r31898 31 31 * @param ContainerInterface $container The DI container 32 32 */ 33 public function __construct(ContainerInterface $container )33 public function __construct(ContainerInterface $container, array $engineIds) 34 34 { 35 35 $this->container = $container; 36 $this->engines = array(); 37 } 38 39 public function setEngineIds($ids) 40 { 41 $this->engines = $ids; 36 $this->engines = $engineIds; 42 37 } 43 38 branches/2.0/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/ActionsHelper.php
r31885 r31898 35 35 36 36 /** 37 * Outputs the Response content for a given controller.38 *39 * @param string $controller A controller name to execute (a string like BlogBundle:Post:index), or a relative URI40 * @param array $options An array of options41 *42 * @see render()43 */44 public function output($controller, array $attributes = array(), array $options = array())45 {46 echo $this->render($controller, $attributes, $options);47 }48 49 /**50 37 * Returns the Response content for a given controller or URI. 51 38 * branches/2.0/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php
r31885 r31898 64 64 $cli = implode(' ', $_SERVER['argv']); 65 65 if (preg_match('/\-\-configuration[= ]+([^ ]+)/', $cli, $matches)) { 66 $dir = $dir.'/'.$matches[1];66 $dir = realpath($matches[1]); 67 67 } elseif (preg_match('/\-c +([^ ]+)/', $cli, $matches)) { 68 $dir = $dir.'/'.$matches[1];68 $dir = realpath($matches[1]); 69 69 } elseif (file_exists(getcwd().'/phpunit.xml') || file_exists(getcwd().'/phpunit.xml.dist')) { 70 70 $dir = getcwd(); branches/2.0/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
r31885 r31898 35 35 36 36 // templating 37 $loader->configLoad(array(array('templating' => array( ))), $container);37 $loader->configLoad(array(array('templating' => array('engines' => array('php')))), $container); 38 38 $this->assertEquals('Symfony\\Bundle\\FrameworkBundle\\Templating\\PhpEngine', $container->getParameter('templating.engine.php.class'), '->templatingLoad() loads the templating.xml file if not already loaded'); 39 39 branches/2.0/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php
r31885 r31898 109 109 } 110 110 111 if (isset($config['cache-warmer'])) { 112 $config['cache_warmer'] = $config['cache-warmer']; 113 } 114 115 if (isset($config['cache_warmer']) && $config['cache_warmer']) { 116 $container->getDefinition('templating.cache_warmer.templates_cache')->addTag('kernel.cache_warmer'); 117 } 118 111 119 $container->setParameter('twig.options', array_replace($container->getParameter('twig.options'), $config)); 112 120 } branches/2.0/src/Symfony/Bundle/TwigBundle/Resources/config/schema/twig-1.0.xsd
r31885 r31898 22 22 <xsd:attribute name="base-template-class" type="xsd:string" /> 23 23 <xsd:attribute name="autoescape" type="xsd:string" /> 24 <xsd:attribute name="cache-warmer" type="cache_warmer" /> 24 25 </xsd:complexType> 25 26 … … 39 40 <xsd:attribute name="id" type="xsd:string" /> 40 41 </xsd:complexType> 42 43 <xsd:simpleType name="cache_warmer"> 44 <xsd:restriction base="xsd:string"> 45 <xsd:enumeration value="false" /> 46 <xsd:enumeration value="true" /> 47 <xsd:enumeration value="full" /> 48 </xsd:restriction> 49 </xsd:simpleType> 41 50 </xsd:schema> branches/2.0/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml
r31885 r31898 18 18 </parameter> 19 19 <parameter key="templating.engine.twig.class">Symfony\Bundle\TwigBundle\TwigEngine</parameter> 20 <parameter key="templating.cache_warmer.templates_cache.class">Symfony\Bundle\TwigBundle\CacheWarmer\TemplateCacheCacheWarmer</parameter> 20 21 </parameters> 21 22 … … 26 27 </service> 27 28 29 <service id="templating.cache_warmer.templates_cache" class="%templating.cache_warmer.templates_cache.class%" public="false"> 30 <argument type="service" id="service_container" /> 31 </service> 32 28 33 <service id="twig.loader" class="%twig.loader.class%"> 29 34 <argument type="service" id="templating.locator" /> 30 35 </service> 31 36 32 <service id="templating.engine.twig" class="%templating.engine.twig.class%"> 33 <tag name="templating.engine" priority="255" /> 37 <service id="templating.engine.twig" class="%templating.engine.twig.class%" public="false"> 34 38 <argument type="service" id="service_container" /> 35 39 <argument type="service" id="twig" /> branches/2.0/src/Symfony/Bundle/WebProfilerBundle/Resources/config/toolbar.xml
r31885 r31898 11 11 12 12 <services> 13 <service id="debug.toolbar" class="%debug.toolbar.class%" public="false">14 <tag name="kernel.listener" priority="-128" />13 <service id="debug.toolbar" class="%debug.toolbar.class%"> 14 <tag name="kernel.listener" event="core.response" method="handle" priority="-128" /> 15 15 <argument type="service" id="http_kernel" /> 16 16 <argument>%debug.toolbar.intercept_redirects%</argument> branches/2.0/src/Symfony/Bundle/WebProfilerBundle/WebDebugToolbarListener.php
r31885 r31898 22 22 * WebDebugToolbarListener injects the Web Debug Toolbar. 23 23 * 24 * The handle method must be connected to the core.response event. 25 * 24 26 * @author Fabien Potencier <fabien.potencier@symfony-project.com> 25 27 */ … … 33 35 $this->kernel = $kernel; 34 36 $this->interceptRedirects = $interceptRedirects; 35 }36 37 /**38 * Registers a core.response listener.39 *40 * @param EventDispatcher $dispatcher An EventDispatcher instance41 * @param integer $priority The priority42 */43 public function register(EventDispatcher $dispatcher, $priority = 0)44 {45 $dispatcher->connect('core.response', array($this, 'handle'), $priority);46 37 } 47 38 branches/2.0/src/Symfony/Component/Console/Output/StreamOutput.php
r31885 r31898 80 80 } 81 81 82 f lush();82 fflush($this->stream); 83 83 } 84 84 branches/2.0/src/Symfony/Component/DependencyInjection/Compiler/CheckReferenceScopePass.php
r31885 r31898 45 45 46 46 foreach ($container->getDefinitions() as $id => $definition) { 47 if ($definition->isSynthetic()) { 48 continue; 49 } 50 47 51 $this->currentId = $id; 48 52 $this->currentScope = $scope = $definition->getScope(); branches/2.0/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php
r31885 r31898 44 44 $this->optimizationPasses = array( 45 45 new ResolveParameterPlaceHoldersPass(), 46 new CheckDefinitionValidityPass(), 46 47 new ResolveReferencesToAliasesPass(), 47 48 new ResolveInterfaceInjectorsPass(), branches/2.0/src/Symfony/Component/DependencyInjection/Compiler/ResolveInterfaceInjectorsPass.php
r31885 r31898 27 27 { 28 28 foreach ($container->getDefinitions() as $definition) { 29 if ($definition->isSynthetic()) { 30 continue; 31 } 32 29 33 $loaded = false; 30 34 foreach ($container->getInterfaceInjectors() as $injector) { branches/2.0/src/Symfony/Component/DependencyInjection/Compiler/ResolveInvalidReferencesPass.php
r31885 r31898 41 41 $this->container = $container; 42 42 foreach ($container->getDefinitions() as $definition) { 43 if ($definition->isSynthetic()) { 44 continue; 45 } 46 43 47 $definition->setArguments( 44 48 $this->processArguments($definition->getArguments()) branches/2.0/src/Symfony/Component/DependencyInjection/Compiler/ResolveReferencesToAliasesPass.php
r31885 r31898 62 62 protected function getDefinitionId($id) 63 63 { 64 if($this->container->hasAlias($id)) {65 return $this->getDefinitionId((string) $this->container->getAlias($id));64 while ($this->container->hasAlias($id)) { 65 $id = (string) $this->container->getAlias($id); 66 66 } 67 67 branches/2.0/src/Symfony/Component/DependencyInjection/Definition.php
r31885 r31898 29 29 protected $tags; 30 30 protected $public; 31 protected $synthetic; 31 32 32 33 /** … … 44 45 $this->tags = array(); 45 46 $this->public = true; 47 $this->synthetic = false; 46 48 } 47 49 … … 296 298 297 299 /** 300 * Whether this definition has a tag with the given name 301 * 302 * @param string $name 303 * 304 * @return Boolean 305 */ 306 public function hasTag($name) 307 { 308 return isset($this->tags[$name]); 309 } 310 311 /** 298 312 * Clears the tags for this definition. 299 313 * … … 379 393 380 394 /** 395 * Sets whether this definition is synthetic, that is not constructed by the 396 * container, but dynamically injected. 397 * 398 * @param Boolean $boolean 399 * 400 * @return Definition the current instance 401 */ 402 public function setSynthetic($boolean) 403 { 404 $this->synthetic = (Boolean) $boolean; 405 406 return $this; 407 } 408 409 /** 410 * Whether this definition is synthetic, that is not constructed by the 411 * container, but dynamically injected. 412 * 413 * @return Boolean 414 */ 415 public function isSynthetic() 416 { 417 return $this->synthetic; 418 } 419 420 /** 381 421 * Sets a configurator to call after the service is fully initialized. 382 422 * branches/2.0/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
r31885 r31898 395 395 396 396 $return = ''; 397 if ($class = $definition->getClass()) { 397 if ($definition->isSynthetic()) { 398 $return = sprintf('@throws \RuntimeException always since this service is expected to be injected dynamically'); 399 } else if ($class = $definition->getClass()) { 398 400 $return = sprintf("@return %s A %s instance.", 0 === strpos($class, '%') ? 'Object' : $class, $class); 399 401 } elseif ($definition->getFactoryService()) { … … 444 446 } 445 447 446 $code .= 447 $this->addServiceInclude($id, $definition). 448 $this->addServiceLocalTempVariables($id, $definition). 449 $this->addServiceInlinedDefinitions($id, $definition). 450 $this->addServiceInstance($id, $definition). 451 $this->addServiceInlinedDefinitionsSetup($id, $definition). 452 $this->addServiceMethodCalls($id, $definition). 453 $this->addServiceConfigurator($id, $definition). 454 $this->addServiceReturn($id, $definition) 455 ; 448 if ($definition->isSynthetic()) { 449 $code .= sprintf(" throw new \RuntimeException('You have requested a synthetic service (\"%s\"). The DIC does not know how to construct this service.');\n }\n", $id); 450 } else { 451 $code .= 452 $this->addServiceInclude($id, $definition). 453 $this->addServiceLocalTempVariables($id, $definition). 454 $this->addServiceInlinedDefinitions($id, $definition). 455 $this->addServiceInstance($id, $definition). 456 $this->addServiceInlinedDefinitionsSetup($id, $definition). 457 $this->addServiceMethodCalls($id, $definition). 458 $this->addServiceConfigurator($id, $definition). 459 $this->addServiceReturn($id, $definition) 460 ; 461 } 456 462 457 463 $this->definitionVariables = null; branches/2.0/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php
r31885 r31898 13 13 14 14 use Symfony\Component\DependencyInjection\ContainerInterface; 15 16 15 use Symfony\Component\DependencyInjection\Alias; 17 18 16 use Symfony\Component\DependencyInjection\InterfaceInjector; 19 17 use Symfony\Component\DependencyInjection\Definition; … … 140 138 $definition = new Definition(); 141 139 142 foreach (array('class', 'scope', 'public', 'factory-method', 'factory-service' ) as $key) {140 foreach (array('class', 'scope', 'public', 'factory-method', 'factory-service', 'synthetic') as $key) { 143 141 if (isset($service[$key])) { 144 142 $method = 'set'.str_replace('-', '', $key); branches/2.0/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php
r31885 r31898 13 13 14 14 use Symfony\Component\DependencyInjection\Alias; 15 16 15 use Symfony\Component\DependencyInjection\ContainerInterface; 17 16 use Symfony\Component\DependencyInjection\InterfaceInjector; … … 149 148 } 150 149 150 if (isset($service['synthetic'])) { 151 $definition->setSynthetic($service['synthetic']); 152 } 153 151 154 if (isset($service['public'])) { 152 155 $definition->setPublic($service['public']); branches/2.0/src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd
r31885 r31898 104 104 <xsd:attribute name="scope" type="xsd:string" /> 105 105 <xsd:attribute name="public" type="boolean" /> 106 <xsd:attribute name="synthetic" type="boolean" /> 106 107 <xsd:attribute name="factory-method" type="xsd:string" /> 107 108 <xsd:attribute name="factory-service" type="xsd:string" /> branches/2.0/src/Symfony/Component/DependencyInjection/ParameterBag/FrozenParameterBag.php
r31885 r31898 21 21 * Constructor. 22 22 * 23 * For performance reasons, the constructor assumes that 24 * all keys are already lowercased. 25 * 26 * This is always the case when used internally. 27 * 23 28 * @param array $parameters An array of parameters 24 29 */ 25 30 public function __construct(array $parameters = array()) 26 31 { 27 foreach ($parameters as $key => $value) { 28 $this->parameters[strtolower($key)] = $value; 29 } 32 $this->parameters = $parameters; 30 33 } 31 34 35 /** 36 * {@inheritdoc} 37 */ 32 38 public function clear() 33 39 { … … 36 42 37 43 /** 38 * Adds parameters to the service container parameters. 39 * 40 * @param array $parameters An array of parameters 44 * {@inheritdoc} 41 45 */ 42 46 public function add(array $parameters) … … 46 50 47 51 /** 48 * Sets a service container parameter. 49 * 50 * @param string $name The parameter name 51 * @param mixed $parameters The parameter value 52 * {@inheritdoc} 52 53 */ 53 54 public function set($name, $value) branches/2.0/src/Symfony/Component/EventDispatcher/EventDispatcher.php
r31885 r31898 49 49 * @param string $name An event name 50 50 * @param mixed|null $listener the listener to remove, or null to remove all 51 * 51 52 * @return void 52 53 */ … … 54 55 { 55 56 if (!isset($this->listeners[$name])) { 56 return false;57 return; 57 58 } 58 59 branches/2.0/src/Symfony/Component/HttpFoundation/FileBag.php
r31885 r31898 40 40 public function set($key, $value) 41 41 { 42 if (is_array($value) ) {42 if (is_array($value) || $value instanceof UploadedFile) { 43 43 parent::set($key, $this->convertFileInformation($value)); 44 44 } … … 59 59 * Converts uploaded files to UploadedFile instances. 60 60 * 61 * @param array $file A (multi-dimensional) array of uploaded file information61 * @param array|UploadedFile $file A (multi-dimensional) array of uploaded file information 62 62 * 63 63 * @return array A (multi-dimensional) array of UploadedFile instances 64 64 */ 65 protected function convertFileInformation( array$file)65 protected function convertFileInformation($file) 66 66 { 67 if ($file instanceof UploadedFile) { 68 return $file; 69 } 67 70 $file = $this->fixPhpFilesArray($file); 68 71 if (is_array($file)) { branches/2.0/src/Symfony/Component/HttpFoundation/Session.php
r31885 r31898 170 170 171 171 /** 172 * Migrates the current session to a new session id while maintaining all 173 * session attributes. 174 */ 175 public function migrate() 176 { 177 $this->storage->regenerate(); 178 } 179 180 /** 172 181 * Returns the session ID 173 182 * branches/2.0/src/Symfony/Component/HttpKernel/Cache/EsiListener.php
r31885 r31898 19 19 * EsiListener adds a Surrogate-Control HTTP header when the Response needs to be parsed for ESI. 20 20 * 21 * The filter method must be connected to the core.response event. 22 * 21 23 * @author Fabien Potencier <fabien.potencier@symfony-project.com> 22 24 */ … … 37 39 38 40 /** 39 * Registers a core.response listener to add the Surrogate-Control header to a Response when needed.40 *41 * @param EventDispatcher $dispatcher An EventDispatcher instance42 * @param integer $priority The priority43 */44 public function register(EventDispatcher $dispatcher, $priority = 0)45 {46 if (null !== $this->esi)47 {48 $dispatcher->connect('core.response', array($this, 'filter'), $priority);49 }50 }51 52 /**53 41 * Filters the Response. 54 42 * … … 58 46 public function filter($event, Response $response) 59 47 { 60 if (HttpKernelInterface::MASTER_REQUEST !== $event->get('request_type') ) {48 if (HttpKernelInterface::MASTER_REQUEST !== $event->get('request_type') || null === $this->esi) { 61 49 return $response; 62 50 } branches/2.0/src/Symfony/Component/HttpKernel/ClassCollectionLoader.php
r31885 r31898 43 43 $classes = array_unique($classes); 44 44 45 if ($adaptive) {46 // don't include already declared classes47 $classes = array_diff($classes, get_declared_classes(), get_declared_interfaces());48 49 // the cache is different depending on which classes are already declared50 $name = $name.'-'.substr(md5(implode('|', $classes)), 0, 5);51 }52 53 45 $cache = $cacheDir.'/'.$name.'.php'; 54 46 … … 56 48 $reload = false; 57 49 if ($autoReload) { 50 if ($adaptive) { 51 // don't include already declared classes 52 $classes = array_diff($classes, get_declared_classes(), get_declared_interfaces()); 53 } 54 58 55 $metadata = $cacheDir.'/'.$name.'.meta'; 59 56 if (!file_exists($metadata) || !file_exists($cache)) { … … 81 78 82 79 return; 80 } 81 82 if ($adaptive) { 83 // don't include already declared classes 84 $classes = array_diff($classes, get_declared_classes(), get_declared_interfaces()); 83 85 } 84 86 branches/2.0/src/Symfony/Component/HttpKernel/Debug/ExceptionListener.php
r31885 r31898 23 23 * ExceptionListener. 24 24 * 25 * The handle method must be connected to the core.exception event. 26 * 25 27 * @author Fabien Potencier <fabien.potencier@symfony-project.com> 26 28 */ … … 34 36 $this->controller = $controller; 35 37 $this->logger = $logger; 36 }37 38 /**39 * Registers a core.exception listener.40 *41 * @param EventDispatcher $dispatcher An EventDispatcher instance42 * @param integer $priority The priority43 */44 public function register(EventDispatcher $dispatcher, $priority = 0)45 {46 $dispatcher->connect('core.exception', array($this, 'handle'), $priority);47 38 } 48 39 branches/2.0/src/Symfony/Component/HttpKernel/Kernel.php
r31885 r31898 30 30 31 31 /** 32 * The Kernel is the heart of the Symfony system. It manages an environment 33 * that can host bundles. 32 * The Kernel is the heart of the Symfony system. 33 * 34 * It manages an environment made of bundles. 34 35 * 35 36 * @author Fabien Potencier <fabien.potencier@symfony-project.org> … … 107 108 108 109 /** 109 * Checks whether the current kernel has been booted or not.110 *111 * @return Boolean $booted112 */113 public function isBooted()114 {115 return $this->booted;116 }117 118 /**119 110 * Boots the current kernel. 120 111 * … … 127 118 { 128 119 if (true === $this->booted) { 129 throw new \LogicException('The kernel is already booted.'); 130 } 131 132 require_once __DIR__.'/bootstrap.php'; 120 return; 121 } 133 122 134 123 // init bundles … … 399 388 // init bundles 400 389 $this->bundles = array(); 390 $this->bundleMap = array(); 401 391 foreach ($this->registerBundles() as $bundle) { 402 392 $name = $bundle->getName(); … … 436 426 $reload = $this->debug ? $this->needsReload($class, $location) : false; 437 427 428 $fresh = false; 438 429 if ($reload || !file_exists($location.'.php')) { 439 430 $container = $this->buildContainer(); 440 431 $this->dumpContainer($container, $class, $location.'.php'); 432 433 $fresh = true; 441 434 } 442 435 … … 445 438 $this->container = new $class(); 446 439 $this->container->set('kernel', $this); 440 441 if ($fresh && 'cli' !== php_sapi_name()) { 442 $this->container->get('cache_warmer')->warmUp($this->container->getParameter('kernel.cache_dir')); 443 } 447 444 } 448 445 branches/2.0/src/Symfony/Component/HttpKernel/Profiler/ProfilerListener.php
r31885 r31898 21 21 * ProfilerListener collects data for the current request by listening to the core.response event. 22 22 * 23 * The handleException method must be connected to the core.exception event. 24 * The handleResponse method must be connected to the core.response event. 25 * 23 26 * @author Fabien Potencier <fabien.potencier@symfony-project.com> 24 27 */ … … 42 45 $this->matcher = $matcher; 43 46 $this->onlyException = $onlyException; 44 }45 46 /**47 * Registers a core.response and core.exception listeners.48 *49 * @param EventDispatcher $dispatcher An EventDispatcher instance50 * @param integer $priority The priority51 */52 public function register(EventDispatcher $dispatcher, $priority = 0)53 {54 $dispatcher->connect('core.exception', array($this, 'handleException'), $priority);55 $dispatcher->connect('core.response', array($this, 'handleResponse'), $priority);56 47 } 57 48 branches/2.0/src/Symfony/Component/HttpKernel/Resources/bin/packager.php
r31885 r31898 24 24 25 25 ClassCollectionLoader::load(array( 26 'Symfony\\Component\\DependencyInjection\\ContainerInterface', 27 'Symfony\\Component\\DependencyInjection\\Container', 28 'Symfony\\Component\\DependencyInjection\\ContainerAwareInterface', 29 'Symfony\\Component\\DependencyInjection\\ContainerAware', 30 'Symfony\\Component\\DependencyInjection\\ParameterBag\\ParameterBagInterface', 31 'Symfony\\Component\\DependencyInjection\\ParameterBag\\ParameterBag', 32 'Symfony\\Component\\DependencyInjection\\ParameterBag\\FrozenParameterBag', 33 34 'Symfony\\Component\\HttpKernel\\Bundle\\BundleInterface', 26 35 'Symfony\\Component\\HttpKernel\\Bundle\\Bundle', 27 'Symfony\\Component\\HttpKernel\\Bundle\\BundleInterface',28 36 'Symfony\\Component\\HttpKernel\\Debug\\ErrorHandler', 29 37 'Symfony\\Component\\HttpKernel\\ClassCollectionLoader', 30 'Symfony\\Component\\HttpKernel\\Debug\\ExceptionListener', 38 'Symfony\\Component\\HttpKernel\\HttpKernelInterface', 39 'Symfony\\Component\\HttpKernel\\Kernel', 31 40 32 'Symfony\\Component\\DependencyInjection\\Container', 33 'Symfony\\Component\\DependencyInjection\\ContainerAwareInterface', 34 'Symfony\\Component\\DependencyInjection\\ContainerInterface', 35 'Symfony\\Component\\DependencyInjection\\ParameterBag\\FrozenParameterBag', 36 'Symfony\\Component\\DependencyInjection\\ParameterBag\\ParameterBagInterface', 41 'Symfony\\Component\\HttpFoundation\\ParameterBag', 42 'Symfony\\Component\\HttpFoundation\\FileBag', 43 'Symfony\\Component\\HttpFoundation\\ServerBag', 44 'Symfony\\Component\\HttpFoundation\\HeaderBag', 45 'Symfony\\Component\\HttpFoundation\\Request', 46 'Symfony\\Component\\HttpFoundation\\UniversalClassLoader', 37 47 38 48 ), __DIR__.'/../..', 'bootstrap', false); branches/2.0/src/Symfony/Component/HttpKernel/ResponseListener.php
r31885 r31898 19 19 * ResponseListener fixes the Response Content-Type. 20 20 * 21 * The filter method must be connected to the core.response event. 22 * 21 23 * @author Fabien Potencier <fabien.potencier@symfony-project.com> 22 24 */ 23 25 class ResponseListener 24 26 { 25 /**26 * Registers a core.response listener to change the Content-Type header based on the Request format.27 *28 * @param EventDispatcher $dispatcher An EventDispatcher instance29 * @param integer $priority The priority30 */31 public function register(EventDispatcher $dispatcher, $priority = 0)32 {33 $dispatcher->connect('core.response', array($this, 'filter'), $priority);34 }35 36 27 /** 37 28 * Filters the Response. branches/2.0/src/Symfony/Component/HttpKernel/Security/Firewall.php
r31885 r31898 25 25 * everything else for instance). 26 26 * 27 * The handle method must be connected to the core.request event. 28 * 27 29 * @author Fabien Potencier <fabien.potencier@symfony-project.com> 28 30 */ … … 38 40 * @param FirewallMap $map A FirewallMap instance 39 41 */ 40 public function __construct(FirewallMapInterface $map )42 public function __construct(FirewallMapInterface $map, EventDispatcher $dispatcher) 41 43 { 42 44 $this->map = $map; 45 $this->dispatcher = $dispatcher; 43 46 $this->currentListeners = array(); 44 }45 46 /**47 * Registers a core.request listener to enforce security.48 *49 * @param EventDispatcher $dispatcher An EventDispatcher instance50 * @param integer $priority The priority51 */52 public function register(EventDispatcher $dispatcher, $priority = 0)53 {54 $dispatcher->connect('core.request', array($this, 'handle'), $priority);55 $this->dispatcher = $dispatcher;56 47 } 57 48 branches/2.0/src/Symfony/Component/HttpKernel/bootstrap.php
r31885 r31898 1 1 <?php 2 namespace Symfony\Component\DependencyInjection 3 { 4 interface ContainerInterface 5 { 6 const EXCEPTION_ON_INVALID_REFERENCE = 1; 7 const NULL_ON_INVALID_REFERENCE = 2; 8 const IGNORE_ON_INVALID_REFERENCE = 3; 9 const SCOPE_CONTAINER = 'container'; 10 const SCOPE_PROTOTYPE = 'prototype'; 11 function set($id, $service, $scope = self::SCOPE_CONTAINER); 12 function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE); 13 function has($id); 14 function enterScope($name); 15 function leaveScope($name); 16 function addScope($name, $parentScope = self::SCOPE_CONTAINER); 17 function hasScope($name); 18 function isScopeActive($name); 19 } 20 } 21 namespace Symfony\Component\DependencyInjection 22 { 23 use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; 24 use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; 25 use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag; 26 class Container implements ContainerInterface 27 { 28 protected $parameterBag; 29 protected $services; 30 protected $loading = array(); 31 public function __construct(ParameterBagInterface $parameterBag = null) 32 { 33 $this->parameterBag = null === $parameterBag ? new ParameterBag() : $parameterBag; 34 $this->services = 35 $this->scopes = 36 $this->scopeChildren = 37 $this->scopedServices = 38 $this->scopeStacks = array(); 39 $this->set('service_container', $this); 40 } 41 public function compile() 42 { 43 $this->parameterBag->resolve(); 44 $this->parameterBag = new FrozenParameterBag($this->parameterBag->all()); 45 } 46 public function isFrozen() 47 { 48 return $this->parameterBag instanceof FrozenParameterBag; 49 } 50 public function getParameterBag() 51 { 52 return $this->parameterBag; 53 } 54 public function getParameter($name) 55 { 56 return $this->parameterBag->get($name); 57 } 58 public function hasParameter($name) 59 { 60 return $this->parameterBag->has($name); 61 } 62 public function setParameter($name, $value) 63 { 64 $this->parameterBag->set($name, $value); 65 } 66 public function set($id, $service, $scope = self::SCOPE_CONTAINER) 67 { 68 if (self::SCOPE_PROTOTYPE === $scope) { 69 throw new \InvalidArgumentException('You cannot set services of scope "prototype".'); 70 } 71 $id = strtolower($id); 72 if (self::SCOPE_CONTAINER !== $scope) { 73 if (!isset($this->scopedServices[$scope])) { 74 throw new \RuntimeException('You cannot set services of inactive scopes.'); 75 } 76 $this->scopedServices[$scope][$id] = $service; 77 } 78 $this->services[$id] = $service; 79 } 80 public function has($id) 81 { 82 $id = strtolower($id); 83 return isset($this->services[$id]) || method_exists($this, 'get'.strtr($id, array('_' => '', '.' => '_')).'Service'); 84 } 85 public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE) 86 { 87 $id = strtolower($id); 88 if (isset($this->services[$id])) { 89 return $this->services[$id]; 90 } 91 if (isset($this->loading[$id])) { 92 throw new \LogicException(sprintf('Circular reference detected for service "%s" (services currently loading: %s).', $id, implode(', ', array_keys($this->loading)))); 93 } 94 if (method_exists($this, $method = 'get'.strtr($id, array('_' => '', '.' => '_')).'Service')) { 95 $this->loading[$id] = true; 96 $service = $this->$method(); 97 unset($this->loading[$id]); 98 return $service; 99 } 100 if (self::EXCEPTION_ON_INVALID_REFERENCE === $invalidBehavior) { 101 throw new \InvalidArgumentException(sprintf('The service "%s" does not exist.', $id)); 102 } 103 } 104 public function getServiceIds() 105 { 106 $ids = array(); 107 $r = new \ReflectionClass($this); 108 foreach ($r->getMethods() as $method) { 109 if (preg_match('/^get(.+)Service$/', $name = $method->getName(), $match)) { 110 $ids[] = self::underscore($match[1]); 111 } 112 } 113 return array_merge($ids, array_keys($this->services)); 114 } 115 public function enterScope($name) 116 { 117 if (!isset($this->scopes[$name])) { 118 throw new \InvalidArgumentException(sprintf('The scope "%s" does not exist.', $name)); 119 } 120 if (self::SCOPE_CONTAINER !== $this->scopes[$name] && !isset($this->scopedServices[$this->scopes[$name]])) { 121 throw new \RuntimeException(sprintf('The parent scope "%s" must be active when entering this scope.', $this->scopes[$name])); 122 } 123 if (isset($this->scopedServices[$name])) { 124 $services = array($this->services, $name => $this->scopedServices[$name]); 125 unset($this->scopedServices[$name]); 126 foreach ($this->scopeChildren[$name] as $child) { 127 $services[$child] = $this->scopedServices[$child]; 128 unset($this->scopedServices[$child]); 129 } 130 $this->services = call_user_func_array('array_diff_key', $services); 131 array_shift($services); 132 if (!isset($this->scopeStacks[$name])) { 133 $this->scopeStacks[$name] = new \SplStack(); 134 } 135 $this->scopeStacks[$name]->push($services); 136 } 137 $this->scopedServices[$name] = array(); 138 } 139 public function leaveScope($name) 140 { 141 if (!isset($this->scopedServices[$name])) { 142 throw new \InvalidArgumentException(sprintf('The scope "%s" is not active.', $name)); 143 } 144 $services = array($this->services, $this->scopedServices[$name]); 145 unset($this->scopedServices[$name]); 146 foreach ($this->scopeChildren[$name] as $child) { 147 if (!isset($this->scopedServices[$child])) { 148 continue; 149 } 150 $services[] = $this->scopedServices[$child]; 151 unset($this->scopedServices[$child]); 152 } 153 $this->services = call_user_func_array('array_diff_key', $services); 154 if (isset($this->scopeStacks[$name]) && count($this->scopeStacks[$name]) > 0) { 155 $services = $this->scopeStacks[$name]->pop(); 156 $this->scopedServices += $services; 157 array_unshift($services, $this->services); 158 $this->services = call_user_func_array('array_merge', $services); 159 } 160 } 161 public function addScope($name, $parentScope = self::SCOPE_CONTAINER) 162 { 163 if (self::SCOPE_CONTAINER === $name || self::SCOPE_PROTOTYPE === $name) { 164 throw new \InvalidArgumentException(sprintf('The scope "%s" is reserved.', $name)); 165 } 166 if (isset($this->scopes[$name])) { 167 throw new \InvalidArgumentException(sprintf('A scope with name "%s" already exists.', $name)); 168 } 169 if (self::SCOPE_CONTAINER !== $parentScope && !isset($this->scopes[$parentScope])) { 170 throw new \InvalidArgumentException(sprintf('The parent scope "%s" does not exist, or is invalid.', $parentScope)); 171 } 172 $this->scopes[$name] = $parentScope; 173 $this->scopeChildren[$name] = array(); 174 if ($parentScope !== self::SCOPE_CONTAINER) { 175 $this->scopeChildren[$parentScope][] = $name; 176 foreach ($this->scopeChildren as $pName => $childScopes) { 177 if (in_array($parentScope, $childScopes, true)) { 178 $this->scopeChildren[$pName][] = $name; 179 } 180 } 181 } 182 } 183 public function hasScope($name) 184 { 185 return isset($this->scopes[$name]); 186 } 187 public function isScopeActive($name) 188 { 189 return isset($this->scopedServices[$name]); 190 } 191 static public function camelize($id) 192 { 193 return preg_replace(array('/(?:^|_)+(.)/e', '/\.(.)/e'), array("strtoupper('\\1')", "'_'.strtoupper('\\1')"), $id); 194 } 195 static public function underscore($id) 196 { 197 return strtolower(preg_replace(array('/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'), array('\\1_\\2', '\\1_\\2'), strtr($id, '_', '.'))); 198 } 199 } 200 } 201 namespace Symfony\Component\DependencyInjection 202 { 203 interface ContainerAwareInterface 204 { 205 function setContainer(ContainerInterface $container = null); 206 } 207 } 208 namespace Symfony\Component\DependencyInjection 209 { 210 class ContainerAware implements ContainerAwareInterface 211 { 212 protected $container; 213 public function setContainer(ContainerInterface $container = null) 214 { 215 $this->container = $container; 216 } 217 } 218 } 219 namespace Symfony\Component\DependencyInjection\ParameterBag 220 { 221 interface ParameterBagInterface 222 { 223 function clear(); 224 function add(array $parameters); 225 function all(); 226 function get($name); 227 function set($name, $value); 228 function has($name); 229 } 230 } 231 namespace Symfony\Component\DependencyInjection\ParameterBag 232 { 233 class ParameterBag implements ParameterBagInterface 234 { 235 protected $parameters; 236 public function __construct(array $parameters = array()) 237 { 238 $this->parameters = array(); 239 $this->add($parameters); 240 } 241 public function clear() 242 { 243 $this->parameters = array(); 244 } 245 public function add(array $parameters) 246 { 247 foreach ($parameters as $key => $value) { 248 $this->parameters[strtolower($key)] = $value; 249 } 250 } 251 public function all() 252 { 253 return $this->parameters; 254 } 255 public function get($name) 256 { 257 $name = strtolower($name); 258 if (!array_key_exists($name, $this->parameters)) { 259 throw new \InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name)); 260 } 261 return $this->parameters[$name]; 262 } 263 public function set($name, $value) 264 { 265 $this->parameters[strtolower($name)] = $value; 266 } 267 public function has($name) 268 { 269 return array_key_exists(strtolower($name), $this->parameters); 270 } 271 public function resolve() 272 { 273 foreach ($this->parameters as $key => $value) { 274 $this->parameters[$key] = $this->resolveValue($value); 275 } 276 } 277 public function resolveValue($value) 278 { 279 if (is_array($value)) { 280 $args = array(); 281 foreach ($value as $k => $v) { 282 $args[$this->resolveValue($k)] = $this->resolveValue($v); 283 } 284 return $args; 285 } 286 if (!is_string($value)) { 287 return $value; 288 } 289 if (preg_match('/^%([^%]+)%$/', $value, $match)) { 290 return $this->get(strtolower($match[1])); 291 } 292 return str_replace('%%', '%', preg_replace_callback(array('/(?<!%)%([^%]+)%/'), array($this, 'resolveValueCallback'), $value)); 293 } 294 protected function resolveValueCallback($match) 295 { 296 return $this->get(strtolower($match[1])); 297 } 298 } 299 } 300 namespace Symfony\Component\DependencyInjection\ParameterBag 301 { 302 class FrozenParameterBag extends ParameterBag 303 { 304 public function __construct(array $parameters = array()) 305 { 306 $this->parameters = $parameters; 307 } 308 public function clear() 309 { 310 throw new \LogicException('Impossible to call clear() on a frozen ParameterBag.'); 311 } 312 public function add(array $parameters) 313 { 314 throw new \LogicException('Impossible to call add() on a frozen ParameterBag.'); 315 } 316 public function set($name, $value) 317 { 318 throw new \LogicException('Impossible to call set() on a frozen ParameterBag.'); 319 } 320 } 321 } 322 namespace Symfony\Component\HttpKernel\Bundle 323 { 324 interface BundleInterface 325 { 326 function boot(); 327 function shutdown(); 328 function getParent(); 329 function getName(); 330 function getNamespace(); 331 function getPath(); 332 } 333 } 2 334 namespace Symfony\Component\HttpKernel\Bundle 3 335 { … … 55 387 } 56 388 } 57 }58 }59 namespace Symfony\Component\HttpKernel\Bundle60 {61 interface BundleInterface62 {63 function boot();64 function shutdown();65 function getParent();66 function getName();67 function getNamespace();68 function getPath();69 389 } 70 390 } … … 115 435 self::$loaded[$name] = true; 116 436 $classes = array_unique($classes); 117 if ($adaptive) {118 $classes = array_diff($classes, get_declared_classes(), get_declared_interfaces());119 $name = $name.'-'.substr(md5(implode('|', $classes)), 0, 5);120 }121 437 $cache = $cacheDir.'/'.$name.'.php'; 122 438 $reload = false; 123 439 if ($autoReload) { 440 if ($adaptive) { 441 $classes = array_diff($classes, get_declared_classes(), get_declared_interfaces()); 442 } 124 443 $metadata = $cacheDir.'/'.$name.'.meta'; 125 444 if (!file_exists($metadata) || !file_exists($cache)) { … … 143 462 require_once $cache; 144 463 return; 464 } 465 if ($adaptive) { 466 $classes = array_diff($classes, get_declared_classes(), get_declared_interfaces()); 145 467 } 146 468 $files = array(); … … 215 537 } 216 538 } 217 namespace Symfony\Component\HttpKernel\Debug 218 { 219 use Symfony\Component\EventDispatcher\EventDispatcher; 220 use Symfony\Component\EventDispatcher\Event; 221 use Symfony\Component\HttpKernel\Log\LoggerInterface; 222 use Symfony\Component\HttpKernel\Log\DebugLoggerInterface; 539 namespace Symfony\Component\HttpKernel 540 { 541 use Symfony\Component\HttpFoundation\Request; 542 interface HttpKernelInterface 543 { 544 const MASTER_REQUEST = 1; 545 const SUB_REQUEST = 2; 546 function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true); 547 } 548 } 549 namespace Symfony\Component\HttpKernel 550 { 551 use Symfony\Component\DependencyInjection\ContainerInterface; 552 use Symfony\Component\DependencyInjection\ContainerBuilder; 553 use Symfony\Component\DependencyInjection\Dumper\PhpDumper; 554 use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; 555 use Symfony\Component\DependencyInjection\Loader\DelegatingLoader; 556 use Symfony\Component\DependencyInjection\Loader\LoaderResolver; 557 use Symfony\Component\DependencyInjection\Loader\LoaderInterface; 558 use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; 559 use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; 560 use Symfony\Component\DependencyInjection\Loader\IniFileLoader; 561 use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; 562 use Symfony\Component\DependencyInjection\Loader\ClosureLoader; 563 use Symfony\Component\HttpFoundation\Request; 223 564 use Symfony\Component\HttpKernel\HttpKernelInterface; 224 use Symfony\Component\HttpKernel\Exception\FlattenException; 225 use Symfony\Component\HttpFoundation\Request; 226 class ExceptionListener 227 { 228 protected $controller; 229 protected $logger; 230 public function __construct($controller, LoggerInterface $logger = null) 231 { 232 $this->controller = $controller; 233 $this->logger = $logger; 234 } 235 public function register(EventDispatcher $dispatcher, $priority = 0) 236 { 237 $dispatcher->connect('core.exception', array($this, 'handle'), $priority); 238 } 239 public function handle(Event $event) 240 { 241 static $handling; 242 if (true === $handling) { 243 return false; 244 } 245 $handling = true; 246 $exception = $event->get('exception'); 247 $request = $event->get('request'); 248 if (null !== $this->logger) { 249 $this->logger->err(sprintf('%s: %s (uncaught exception)', get_class($exception), $exception->getMessage())); 565 use Symfony\Component\HttpKernel\ClassCollectionLoader; 566 use Symfony\Component\HttpKernel\Bundle\BundleInterface; 567 abstract class Kernel implements HttpKernelInterface, \Serializable 568 { 569 protected $bundles; 570 protected $bundleMap; 571 protected $container; 572 protected $rootDir; 573 protected $environment; 574 protected $debug; 575 protected $booted; 576 protected $name; 577 protected $startTime; 578 const VERSION = '2.0.0-DEV'; 579 public function __construct($environment, $debug) 580 { 581 $this->environment = $environment; 582 $this->debug = (Boolean) $debug; 583 $this->booted = false; 584 $this->rootDir = realpath($this->registerRootDir()); 585 $this->name = basename($this->rootDir); 586 if ($this->debug) { 587 ini_set('display_errors', 1); 588 error_reporting(-1); 589 $this->startTime = microtime(true); 250 590 } else { 251 error_log(sprintf('Uncaught PHP Exception %s: "%s" at %s line %s', get_class($exception), $exception->getMessage(), $exception->getFile(), $exception->getLine())); 252 } 253 $logger = null !== $this->logger ? $this->logger->getDebugLogger() : null; 254 $attributes = array( 255 '_controller' => $this->controller, 256 'exception' => FlattenException::create($exception), 257 'logger' => $logger, 258 'format' => 0 === strncasecmp(PHP_SAPI, 'cli', 3) ? 'txt' : $request->getRequestFormat(), 591 ini_set('display_errors', 0); 592 } 593 } 594 public function __clone() 595 { 596 if ($this->debug) { 597 $this->startTime = microtime(true); 598 } 599 $this->booted = false; 600 $this->container = null; 601 } 602 abstract public function registerRootDir(); 603 abstract public function registerBundles(); 604 abstract public function registerContainerConfiguration(LoaderInterface $loader); 605 public function boot() 606 { 607 if (true === $this->booted) { 608 return; 609 } 610 $this->initializeBundles(); 611 $this->initializeContainer(); 612 ClassCollectionLoader::load( 613 $this->container->getParameter('kernel.compiled_classes'), 614 $this->container->getParameter('kernel.cache_dir'), 615 'classes', 616 $this->container->getParameter('kernel.debug'), 617 true 259 618 ); 260 $request = $request->duplicate(null, null, $attributes); 261 try { 262 $response = $event->getSubject()->handle($request, HttpKernelInterface::SUB_REQUEST, true); 263 } catch (\Exception $e) { 264 $message = sprintf('Exception thrown when handling an exception (%s: %s)', get_class($e), $e->getMessage()); 265 if (null !== $this->logger) { 266 $this->logger->err($message); 619 foreach ($this->bundles as $bundle) { 620 $bundle->setContainer($this->container); 621 $bundle->boot(); 622 } 623 $this->booted = true; 624 } 625 public function shutdown() 626 { 627 $this->booted = false; 628 foreach ($this->bundles as $bundle) { 629 $bundle->shutdown(); 630 $bundle->setContainer(null); 631 } 632 $this->container = null; 633 } 634 public function reboot() 635 { 636 $this->shutdown(); 637 $this->boot(); 638 } 639 public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) 640 { 641 if (false === $this->booted) { 642 $this->boot(); 643 } 644 return $this->container->get('http_kernel')->handle($request, $type, $catch); 645 } 646 public function getBundles() 647 { 648 return $this->bundles; 649 } 650 public function isClassInActiveBundle($class) 651 { 652 foreach ($this->bundles as $bundle) { 653 $bundleClass = get_class($bundle); 654 if (0 === strpos($class, substr($bundleClass, 0, strrpos($bundleClass, '\\')))) { 655 return true; 656 } 657 } 658 return false; 659 } 660 public function getBundle($name, $first = true) 661 { 662 if (!isset($this->bundleMap[$name])) { 663 throw new \InvalidArgumentException(sprintf('Bundle "%s" does not exist or it is not enabled.', $name)); 664 } 665 if (true === $first) { 666 return $this->bundleMap[$name][0]; 667 } elseif (false === $first) { 668 return $this->bundleMap[$name]; 669 } 670 } 671 public function locateResource($name, $dir = null, $first = true) 672 { 673 if ('@' !== $name[0]) { 674 throw new \InvalidArgumentException(sprintf('A resource name must start with @ ("%s" given).', $name)); 675 } 676 if (false !== strpos($name, '..')) { 677 throw new \RuntimeException(sprintf('File name "%s" contains invalid characters (..).', $name)); 678 } 679 $name = substr($name, 1); 680 list($bundle, $path) = explode('/', $name, 2); 681 $isResource = 0 === strpos($path, 'Resources'); 682 $files = array(); 683 if (true === $isResource && null !== $dir && file_exists($file = $dir.'/'.$bundle.'/'.substr($path, 10))) { 684 if ($first) { 685 return $file; 686 } 687 $files[] = $file; 688 } 689 foreach ($this->getBundle($bundle, false) as $bundle) { 690 if (file_exists($file = $bundle->getPath().'/'.$path)) { 691 if ($first) { 692 return $file; 693 } 694 $files[] = $file; 695 } 696 } 697 if ($files) { 698 return $files; 699 } 700 throw new \InvalidArgumentException(sprintf('Unable to find file "@%s".', $name)); 701 } 702 public function getName() 703 { 704 return $this->name; 705 } 706 public function getSafeName() 707 { 708 return preg_replace('/[^a-zA-Z0-9_]+/', '', $this->name); 709 } 710 public function getEnvironment() 711 { 712 return $this->environment; 713 } 714 public function isDebug() 715 { 716 return $this->debug; 717 } 718 public function getRootDir() 719 { 720 return $this->rootDir; 721 } 722 public function getContainer() 723 { 724 return $this->container; 725 } 726 public function getStartTime() 727 { 728 return $this->debug ? $this->startTime : -INF; 729 } 730 public function getCacheDir() 731 { 732 return $this->rootDir.'/cache/'.$this->environment; 733 } 734 public function getLogDir() 735 { 736 return $this->rootDir.'/logs'; 737 } 738 protected function initializeBundles() 739 { 740 $this->bundles = array(); 741 $this->bundleMap = array(); 742 foreach ($this->registerBundles() as $bundle) { 743 $name = $bundle->getName(); 744 $this->bundles[$name] = $bundle; 745 if (!isset($this->bundleMap[$name])) { 746 $this->bundleMap[$name] = array(); 747 } 748 $this->bundleMap[$name][] = $bundle; 749 } 750 $extended = array(); 751 foreach ($this->bundles as $name => $bundle) { 752 $parent = $bundle; 753 $first = true; 754 while ($parentName = $parent->getParent()) { 755 if (!isset($this->bundles[$parentName])) { 756 throw new \LogicException(sprintf('Bundle "%s" extends bundle "%s", which is not registered.', $name, $parentName)); 757 } 758 if ($first && isset($extended[$parentName])) { 759 throw new \LogicException(sprintf('Bundle "%s" is directly extended by two bundles "%s" and "%s".', $parentName, $name, $extended[$parentName])); 760 } 761 $first = false; 762 $parent = $this->bundles[$parentName]; 763 $extended[$parentName] = $name; 764 array_unshift($this->bundleMap[$parentName], $bundle); 765 } 766 } 767 } 768 protected function initializeContainer() 769 { 770 $class = $this->getSafeName().ucfirst($this->environment).($this->debug ? 'Debug' : '').'ProjectContainer'; 771 $location = $this->getCacheDir().'/'.$class; 772 $reload = $this->debug ? $this->needsReload($class, $location) : false; 773 $fresh = false; 774 if ($reload || !file_exists($location.'.php')) { 775 $container = $this->buildContainer(); 776 $this->dumpContainer($container, $class, $location.'.php'); 777 $fresh = true; 778 } 779 require_once $location.'.php'; 780 $this->container = new $class(); 781 $this->container->set('kernel', $this); 782 if ($fresh && 'cli' !== php_sapi_name()) { 783 $this->container->get('cache_warmer')->warmUp($this->container->getParameter('kernel.cache_dir')); 784 } 785 } 786 public function getKernelParameters() 787 { 788 $bundles = array(); 789 foreach ($this->bundles as $name => $bundle) { 790 $bundles[$name] = get_class($bundle); 791 } 792 return array_merge( 793 array( 794 'kernel.root_dir' => $this->rootDir, 795 'kernel.environment' => $this->environment, 796 'kernel.debug' => $this->debug, 797 'kernel.name' => $this->name, 798 'kernel.cache_dir' => $this->getCacheDir(), 799 'kernel.logs_dir' => $this->getLogDir(), 800 'kernel.bundles' => $bundles, 801 'kernel.charset' => 'UTF-8', 802 ), 803 $this->getEnvParameters() 804 ); 805 } 806 protected function getEnvParameters() 807 { 808 $parameters = array(); 809 foreach ($_SERVER as $key => $value) { 810 if ('SYMFONY__' === substr($key, 0, 9)) { 811 $parameters[strtolower(str_replace('__', '.', substr($key, 9)))] = $value; 812 } 813 } 814 return $parameters; 815 } 816 protected function needsReload($class, $location) 817 { 818 if (!file_exists($location.'.meta') || !file_exists($location.'.php')) { 819 return true; 820 } 821 $meta = unserialize(file_get_contents($location.'.meta')); 822 $time = filemtime($location.'.php'); 823 foreach ($meta as $resource) { 824 if (!$resource->isUptodate($time)) { 825 return true; 826 } 827 } 828 return false; 829 } 830 protected function buildContainer() 831 { 832 $parameterBag = new ParameterBag($this->getKernelParameters()); 833 $container = new ContainerBuilder($parameterBag); 834 foreach ($this->bundles as $bundle) { 835 $bundle->registerExtensions($container); 836 if ($this->debug) { 837 $container->addObjectResource($bundle); 838 } 839 } 840 if (null !== $cont = $this->registerContainerConfiguration($this->getContainerLoader($container))) { 841 $container->merge($cont); 842 } 843 $container->compile(); 844 return $container; 845 } 846 protected function dumpContainer(ContainerBuilder $container, $class, $file) 847 { 848 foreach (array('cache', 'logs') as $name) { 849 $dir = $container->getParameter(sprintf('kernel.%s_dir', $name)); 850 if (!is_dir($dir)) { 851 if (false === @mkdir($dir, 0777, true)) { 852 die(sprintf('Unable to create the %s directory (%s)', $name, dirname($dir))); 853 } 854 } elseif (!is_writable($dir)) { 855 die(sprintf('Unable to write in the %s directory (%s)', $name, $dir)); 856 } 857 } 858 $dumper = new PhpDumper($container); 859 $content = $dumper->dump(array('class' => $class)); 860 if (!$this->debug) { 861 $content = self::stripComments($content); 862 } 863 $this->writeCacheFile($file, $content); 864 if ($this->debug) { 865 $container->addObjectResource($this); 866 $this->writeCacheFile($this->getCacheDir().'/'.$class.'.meta', serialize($container->getResources())); 867 } 868 } 869 protected function getContainerLoader(ContainerInterface $container) 870 { 871 $resolver = new LoaderResolver(array( 872 new XmlFileLoader($container), 873 new YamlFileLoader($container), 874 new IniFileLoader($container), 875 new PhpFileLoader($container), 876 new ClosureLoader($container), 877 )); 878 return new DelegatingLoader($resolver); 879 } 880 static public function stripComments($source) 881 { 882 if (!function_exists('token_get_all')) { 883 return $source; 884 } 885 $output = ''; 886 foreach (token_get_all($source) as $token) { 887 if (is_string($token)) { 888 $output .= $token; 889 } elseif (!in_array($token[0], array(T_COMMENT, T_DOC_COMMENT))) { 890 $output .= $token[1]; 891 } 892 } 893 $output = preg_replace(array('/\s+$/Sm', '/\n+/S'), "\n", $output); 894 return $output; 895 } 896 protected function writeCacheFile($file, $content) 897 { 898 $tmpFile = tempnam(dirname($file), basename($file)); 899 if (false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $file)) { 900 chmod($file, 0644); 901 return; 902 } 903 throw new \RuntimeException(sprintf('Failed to write cache file "%s".', $file)); 904 } 905 public function serialize() 906 { 907 return serialize(array($this->environment, $this->debug)); 908 } 909 public function unserialize($data) 910 { 911 list($environment, $debug) = unserialize($data); 912 $this->__construct($environment, $debug); 913 } 914 } 915 } 916 namespace Symfony\Component\HttpFoundation 917 { 918 class ParameterBag 919 { 920 protected $parameters; 921 public function __construct(array $parameters = array()) 922 { 923 $this->replace($parameters); 924 } 925 public function all() 926 { 927 return $this->parameters; 928 } 929 public function keys() 930 { 931 return array_keys($this->parameters); 932 } 933 public function replace(array $parameters = array()) 934 { 935 $this->parameters = $parameters; 936 } 937 public function add(array $parameters = array()) 938 { 939 $this->parameters = array_replace($this->parameters, $parameters); 940 } 941 public function get($key, $default = null) 942 { 943 return array_key_exists($key, $this->parameters) ? $this->parameters[$key] : $default; 944 } 945 public function set($key, $value) 946 { 947 $this->parameters[$key] = $value; 948 } 949 public function has($key) 950 { 951 return array_key_exists($key, $this->parameters); 952 } 953 public function remove($key) 954 { 955 unset($this->parameters[$key]); 956 } 957 public function getAlpha($key, $default = '') 958 { 959 return preg_replace('/[^[:alpha:]]/', '', $this->get($key, $default)); 960 } 961 public function getAlnum($key, $default = '') 962 { 963 return preg_replace('/[^[:alnum:]]/', '', $this->get($key, $default)); 964 } 965 public function getDigits($key, $default = '') 966 { 967 return preg_replace('/[^[:digit:]]/', '', $this->get($key, $default)); 968 } 969 public function getInt($key, $default = 0) 970 { 971 return (int) $this->get($key, $default); 972 } 973 } 974 } 975 namespace Symfony\Component\HttpFoundation 976 { 977 use Symfony\Component\HttpFoundation\File\UploadedFile; 978 class FileBag extends ParameterBag 979 { 980 private $fileKeys = array('error', 'name', 'size', 'tmp_name', 'type'); 981 public function replace(array $files = array()) 982 { 983 $this->parameters = array(); 984 $this->add($files); 985 } 986 public function set($key, $value) 987 { 988 if (is_array($value) || $value instanceof UploadedFile) { 989 parent::set($key, $this->convertFileInformation($value)); 990 } 991 } 992 public function add(array $files = array()) 993 { 994 foreach ($files as $key => $file) { 995 $this->set($key, $file); 996 } 997 } 998 protected function convertFileInformation($file) 999 { 1000 if ($file instanceof UploadedFile) { 1001 return $file; 1002 } 1003 $file = $this->fixPhpFilesArray($file); 1004 if (is_array($file)) { 1005 $keys = array_keys($file); 1006 sort($keys); 1007 if ($keys == $this->fileKeys) { 1008 $file['error'] = (int) $file['error']; 1009 } 1010 if ($keys != $this->fileKeys) { 1011 $file = array_map(array($this, 'convertFileInformation'), $file); 1012 } else 1013 if ($file['error'] === UPLOAD_ERR_NO_FILE) { 1014 $file = null; 1015 } else { 1016 $file = new UploadedFile($file['tmp_name'], $file['name'], 1017 $file['type'], $file['size'], $file['error']); 1018 } 1019 } 1020 return $file; 1021 } 1022 protected function fixPhpFilesArray($data) 1023 { 1024 if (! is_array($data)) { 1025 return $data; 1026 } 1027 $keys = array_keys($data); 1028 sort($keys); 1029 if ($this->fileKeys != $keys || ! isset($data['name']) || 1030 ! is_array($data['name'])) { 1031 return $data; 1032 } 1033 $files = $data; 1034 foreach ($this->fileKeys as $k) { 1035 unset($files[$k]); 1036 } 1037 foreach (array_keys($data['name']) as $key) { 1038 $files[$key] = $this->fixPhpFilesArray(array( 1039 'error' => $data['error'][$key], 1040 'name' => $data['name'][$key], 'type' => $data['type'][$key], 1041 'tmp_name' => $data['tmp_name'][$key], 1042 'size' => $data['size'][$key] 1043 )); 1044 } 1045 return $files; 1046 } 1047 } 1048 } 1049 namespace Symfony\Component\HttpFoundation 1050 { 1051 class ServerBag extends ParameterBag 1052 { 1053 public function getHeaders() 1054 { 1055 $headers = array(); 1056 foreach ($this->parameters as $key => $value) { 1057 if ('http_' === strtolower(substr($key, 0, 5))) { 1058 $headers[substr($key, 5)] = $value; 1059 } 1060 } 1061 return $headers; 1062 } 1063 } 1064 } 1065 namespace Symfony\Component\HttpFoundation 1066 { 1067 class HeaderBag 1068 { 1069 protected $headers; 1070 protected $cookies; 1071 protected $cacheControl; 1072 public function __construct(array $headers = array()) 1073 { 1074 $this->cacheControl = array(); 1075 $this->cookies = array(); 1076 $this->replace($headers); 1077 } 1078 public function all() 1079 { 1080 return $this->headers; 1081 } 1082 public function keys() 1083 { 1084 return array_keys($this->headers); 1085 } 1086 public function replace(array $headers = array()) 1087 { 1088 $this->headers = array(); 1089 $this->add($headers); 1090 } 1091 public function add(array $headers) 1092 { 1093 foreach ($headers as $key => $values) { 1094 $this->set($key, $values); 1095 } 1096 } 1097 public function get($key, $default = null, $first = true) 1098 { 1099 $key = strtr(strtolower($key), '_', '-'); 1100 if (!array_key_exists($key, $this->headers)) { 1101 if (null === $default) { 1102 return $first ? null : array(); 267 1103 } else { 268 error_log($message); 269 } 270 throw $exception; 271 } 272 $event->setReturnValue($response); 273 $handling = false; 274 return true; 275 } 276 } 277 } 278 namespace Symfony\Component\DependencyInjection 279 { 280 use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; 281 use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; 282 use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag; 283 class Container implements ContainerInterface 284 { 285 protected $parameterBag; 286 protected $services; 287 protected $loading = array(); 288 public function __construct(ParameterBagInterface $parameterBag = null) 289 { 290 $this->parameterBag = null === $parameterBag ? new ParameterBag() : $parameterBag; 291 $this->services = 292 $this->scopes = 293 $this->scopeChildren = 294 $this->scopedServices = 295 $this->scopeStacks = array(); 296 $this->set('service_container', $this); 297 } 298 public function compile() 299 { 300 $this->parameterBag->resolve(); 301 $this->parameterBag = new FrozenParameterBag($this->parameterBag->all()); 302 } 303 public function isFrozen() 304 { 305 return $this->parameterBag instanceof FrozenParameterBag; 306 } 307 public function getParameterBag() 308 { 309 return $this->parameterBag; 310 } 311 public function getParameter($name) 312 { 313 return $this->parameterBag->get($name); 314 } 315 public function hasParameter($name) 316 { 317 return $this->parameterBag->has($name); 318 } 319 public function setParameter($name, $value) 320 { 321 $this->parameterBag->set($name, $value); 322 } 323 public function set($id, $service, $scope = self::SCOPE_CONTAINER) 324 { 325 if (self::SCOPE_PROTOTYPE === $scope) { 326 throw new \InvalidArgumentException('You cannot set services of scope "prototype".'); 327 } 328 $id = strtolower($id); 329 if (self::SCOPE_CONTAINER !== $scope) { 330 if (!isset($this->scopedServices[$scope])) { 331 throw new \RuntimeException('You cannot set services of inactive scopes.'); 332 } 333 $this->scopedServices[$scope][$id] = $service; 334 } 335 $this->services[$id] = $service; 336 } 337 public function has($id) 338 { 339 $id = strtolower($id); 340 return isset($this->services[$id]) || method_exists($this, 'get'.strtr($id, array('_' => '', '.' => '_')).'Service'); 341 } 342 public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE) 343 { 344 $id = strtolower($id); 345 if (isset($this->services[$id])) { 346 return $this->services[$id]; 347 } 348 if (isset($this->loading[$id])) { 349 throw new \LogicException(sprintf('Circular reference detected for service "%s" (services currently loading: %s).', $id, implode(', ', array_keys($this->loading)))); 350 } 351 if (method_exists($this, $method = 'get'.strtr($id, array('_' => '', '.' => '_')).'Service')) { 352 $this->loading[$id] = true; 353 $service = $this->$method(); 354 unset($this->loading[$id]); 355 return $service; 356 } 357 if (self::EXCEPTION_ON_INVALID_REFERENCE === $invalidBehavior) { 358 throw new \InvalidArgumentException(sprintf('The service "%s" does not exist.', $id)); 359 } 360 } 361 public function getServiceIds() 362 { 363 $ids = array(); 364 $r = new \ReflectionClass($this); 365 foreach ($r->getMethods() as $method) { 366 if (preg_match('/^get(.+)Service$/', $name = $method->getName(), $match)) { 367 $ids[] = self::underscore($match[1]); 368 } 369 } 370 return array_merge($ids, array_keys($this->services)); 371 } 372 public function enterScope($name) 373 { 374 if (!isset($this->scopes[$name])) { 375 throw new \InvalidArgumentException(sprintf('The scope "%s" does not exist.', $name)); 376 } 377 if (self::SCOPE_CONTAINER !== $this->scopes[$name] && !isset($this->scopedServices[$this->scopes[$name]])) { 378 throw new \RuntimeException(sprintf('The parent scope "%s" must be active when entering this scope.', $this->scopes[$name])); 379 } 380 if (isset($this->scopedServices[$name])) { 381 $services = array($this->services, $name => $this->scopedServices[$name]); 382 unset($this->scopedServices[$name]); 383 foreach ($this->scopeChildren[$name] as $child) { 384 $services[$child] = $this->scopedServices[$child]; 385 unset($this->scopedServices[$child]); 386 } 387 $this->services = call_user_func_array('array_diff_key', $services); 388 array_shift($services); 389 if (!isset($this->scopeStacks[$name])) { 390 $this->scopeStacks[$name] = new \SplStack(); 391 } 392 $this->scopeStacks[$name]->push($services); 393 } 394 $this->scopedServices[$name] = array(); 395 } 396 public function leaveScope($name) 397 { 398 if (!isset($this->scopedServices[$name])) { 399 throw new \InvalidArgumentException(sprintf('The scope "%s" is not active.', $name)); 400 } 401 $services = array($this->services, $this->scopedServices[$name]); 402 unset($this->scopedServices[$name]); 403 foreach ($this->scopeChildren[$name] as $child) { 404 if (!isset($this->scopedServices[$child])) { 405 continue; 406 } 407 $services[] = $this->scopedServices[$child]; 408 unset($this->scopedServices[$child]); 409 } 410 $this->services = call_user_func_array('array_diff_key', $services); 411 if (isset($this->scopeStacks[$name]) && count($this->scopeStacks[$name]) > 0) { 412 $services = $this->scopeStacks[$name]->pop(); 413 $this->scopedServices += $services; 414 array_unshift($services, $this->services); 415 $this->services = call_user_func_array('array_merge', $services); 416 } 417 } 418 public function addScope($name, $parentScope = self::SCOPE_CONTAINER) 419 { 420 if (self::SCOPE_CONTAINER === $name || self::SCOPE_PROTOTYPE === $name) { 421 throw new \InvalidArgumentException(sprintf('The scope "%s" is reserved.', $name)); 422 } 423 if (isset($this->scopes[$name])) { 424 throw new \InvalidArgumentException(sprintf('A scope with name "%s" already exists.', $name)); 425 } 426 if (self::SCOPE_CONTAINER !== $parentScope && !isset($this->scopes[$parentScope])) { 427 throw new \InvalidArgumentException(sprintf('The parent scope "%s" does not exist, or is invalid.', $parentScope)); 428 } 429 $this->scopes[$name] = $parentScope; 430 $this->scopeChildren[$name] = array(); 431 if ($parentScope !== self::SCOPE_CONTAINER) { 432 $this->scopeChildren[$parentScope][] = $name; 433 foreach ($this->scopeChildren as $pName => $childScopes) { 434 if (in_array($parentScope, $childScopes, true)) { 435 $this->scopeChildren[$pName][] = $name; 1104 return $first ? $default : array($default); 1105 } 1106 } 1107 if ($first) { 1108 return count($this->headers[$key]) ? $this->headers[$key][0] : $default; 1109 } else { 1110 return $this->headers[$key]; 1111 } 1112 } 1113 public function set($key, $values, $replace = true) 1114 { 1115 $key = strtr(strtolower($key), '_', '-'); 1116 if (!is_array($values)) { 1117 $values = array($values); 1118 } 1119 if (true === $replace || !isset($this->headers[$key])) { 1120 $this->headers[$key] = $values; 1121 } else { 1122 $this->headers[$key] = array_merge($this->headers[$key], $values); 1123 } 1124 if ('cache-control' === $key) { 1125 $this->cacheControl = $this->parseCacheControl($values[0]); 1126 } 1127 } 1128 public function has($key) 1129 { 1130 return array_key_exists(strtr(strtolower($key), '_', '-'), $this->headers); 1131 } 1132 public function contains($key, $value) 1133 { 1134 return in_array($value, $this->get($key, null, false)); 1135 } 1136 public function remove($key) 1137 { 1138 $key = strtr(strtolower($key), '_', '-'); 1139 unset($this->headers[$key]); 1140 if ('cache-control' === $key) { 1141 $this->cacheControl = array(); 1142 } 1143 } 1144 public function setCookie(Cookie $cookie) 1145 { 1146 $this->cookies[$cookie->getName()] = $cookie; 1147 } 1148 public function removeCookie($name) 1149 { 1150 unset($this->cookies[$name]); 1151 } 1152 public function hasCookie($name) 1153 { 1154 return isset($this->cookies[$name]); 1155 } 1156 public function getCookie($name) 1157 { 1158 if (!$this->hasCookie($name)) { 1159 throw new \InvalidArgumentException(sprintf('There is no cookie with name "%s".', $name)); 1160 } 1161 return $this->cookies[$name]; 1162 } 1163 public function getCookies() 1164 { 1165 return $this->cookies; 1166 } 1167 public function getDate($key, \DateTime $default = null) 1168 { 1169 if (null === $value = $this->get($key)) { 1170 return $default; 1171 } 1172 if (false === $date = \DateTime::createFromFormat(DATE_RFC2822, $value)) { 1173 throw new \RuntimeException(sprintf('The %s HTTP header is not parseable (%s).', $key, $value)); 1174 } 1175 return $date; 1176 } 1177 public function addCacheControlDirective($key, $value = true) 1178 { 1179 $this->cacheControl[$key] = $value; 1180 $this->set('Cache-Control', $this->getCacheControlHeader()); 1181 } 1182 public function hasCacheControlDirective($key) 1183 { 1184 return array_key_exists($key, $this->cacheControl); 1185 } 1186 public function getCacheControlDirective($key) 1187 { 1188 return array_key_exists($key, $this->cacheControl) ? $this->cacheControl[$key] : null; 1189 } 1190 public function removeCacheControlDirective($key) 1191 { 1192 unset($this->cacheControl[$key]); 1193 $this->set('Cache-Control', $this->getCacheControlHeader()); 1194 } 1195 protected function getCacheControlHeader() 1196 { 1197 $parts = array(); 1198 ksort($this->cacheControl); 1199 foreach ($this->cacheControl as $key => $value) { 1200 if (true === $value) { 1201 $parts[] = $key; 1202 } else { 1203 if (preg_match('#[^a-zA-Z0-9._-]#', $value)) { 1204 $value = '"'.$value.'"'; 436 1205 } 437 } 438 } 439 } 440 public function hasScope($name) 441 { 442 return isset($this->scopes[$name]); 443 } 444 public function isScopeActive($name) 445 { 446 return isset($this->scopedServices[$name]); 447 } 448 static public function camelize($id) 449 { 450 return preg_replace(array('/(?:^|_)+(.)/e', '/\.(.)/e'), array("strtoupper('\\1')", "'_'.strtoupper('\\1')"), $id); 451 } 452 static public function underscore($id) 453 { 454 return strtolower(preg_replace(array('/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'), array('\\1_\\2', '\\1_\\2'), strtr($id, '_', '.'))); 455 } 456 } 457 } 458 namespace Symfony\Component\DependencyInjection 459 { 460 interface ContainerAwareInterface 461 { 462 function setContainer(ContainerInterface $container = null); 463 } 464 } 465 namespace Symfony\Component\DependencyInjection 466 { 467 interface ContainerInterface 468 { 469 const EXCEPTION_ON_INVALID_REFERENCE = 1; 470 const NULL_ON_INVALID_REFERENCE = 2; 471 const IGNORE_ON_INVALID_REFERENCE = 3; 472 const SCOPE_CONTAINER = 'container'; 473 const SCOPE_PROTOTYPE = 'prototype'; 474 function set($id, $service, $scope = self::SCOPE_CONTAINER); 475 function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE); 476 function has($id); 477 function enterScope($name); 478 function leaveScope($name); 479 function addScope($name, $parentScope = self::SCOPE_CONTAINER); 480 function hasScope($name); 481 function isScopeActive($name); 482 } 483 } 484 namespace Symfony\Component\DependencyInjection\ParameterBag 485 { 486 class FrozenParameterBag extends ParameterBag 487 { 488 public function __construct(array $parameters = array()) 489 { 490 foreach ($parameters as $key => $value) { 491 $this->parameters[strtolower($key)] = $value; 492 } 493 } 494 public function clear() 495 { 496 throw new \LogicException('Impossible to call clear() on a frozen ParameterBag.'); 497 } 498 public function add(array $parameters) 499 { 500 throw new \LogicException('Impossible to call add() on a frozen ParameterBag.'); 501 } 502 public function set($name, $value) 503 { 504 throw new \LogicException('Impossible to call set() on a frozen ParameterBag.'); 505 } 506 } 507 } 508 namespace Symfony\Component\DependencyInjection\ParameterBag 509 { 510 interface ParameterBagInterface 511 { 512 function clear(); 513 function add(array $parameters); 514 function all(); 515 function get($name); 516 function set($name, $value); 517 function has($name); 518 } 519 } 1206 $parts[] = "$key=$value"; 1207 } 1208 } 1209 return implode(', ', $parts); 1210 } 1211 protected function parseCacheControl($header) 1212 { 1213 $cacheControl = array(); 1214 preg_match_all('#([a-zA-Z][a-zA-Z_-]*)\s*(?:=(?:"([^"]*)"|([^ \t",;]*)))?#', $header, $matches, PREG_SET_ORDER); 1215 foreach ($matches as $match) { 1216 $cacheControl[strtolower($match[1])] = isset($match[2]) && $match[2] ? $match[2] : (isset($match[3]) ? $match[3] : true); 1217 } 1218 return $cacheControl; 1219 } 1220 } 1221 } 1222 namespace Symfony\Component\HttpFoundation 1223 { 1224 use Symfony\Component\HttpFoundation\SessionStorage\NativeSessionStorage; 1225 use Symfony\Component\HttpFoundation\File\UploadedFile; 1226 class Request 1227 { 1228 public $attributes; 1229 public $request; 1230 public $query; 1231 public $server; 1232 public $files; 1233 public $cookies; 1234 public $headers; 1235 protected $content; 1236 protected $languages; 1237 protected $charsets; 1238 protected $acceptableContentTypes; 1239 protected $pathInfo; 1240 protected $requestUri; 1241 protected $baseUrl; 1242 protected $basePath; 1243 protected $method; 1244 protected $format; 1245 protected $session; 1246 static protected $formats; 1247 public function __construct(array $query = null, array $request = null, array $attributes = null, array $cookies = null, array $files = null, array $server = null) 1248 { 1249 $this->initialize($query, $request, $attributes, $cookies, $files, $server); 1250 } 1251 public function initialize(array $query = null, array $request = null, array $attributes = null, array $cookies = null, array $files = null, array $server = null) 1252 { 1253 $this->request = new ParameterBag(null !== $request ? $request : $_POST); 1254 $this->query = new ParameterBag(null !== $query ? $query : $_GET); 1255 $this->attributes = new ParameterBag(null !== $attributes ? $attributes : array()); 1256 $this->cookies = new ParameterBag(null !== $cookies ? $cookies : $_COOKIE); 1257 $this->files = new FileBag(null !== $files ? $files : $_FILES); 1258 $this->server = new ServerBag(null !== $server ? $server : $_SERVER); 1259 $this->headers = new HeaderBag($this->server->getHeaders()); 1260 $this->content = null; 1261 $this->languages = null; 1262 $this->charsets = null; 1263 $this->acceptableContentTypes = null; 1264 $this->pathInfo = null; 1265 $this->requestUri = null; 1266 $this->baseUrl = null; 1267 $this->basePath = null; 1268 $this->method = null; 1269 $this->format = null; 1270 } 1271 static public function create($uri, $method = 'GET', $parameters = array(), $cookies = array(), $files = array(), $server = array()) 1272 { 1273 $defaults = array( 1274 'SERVER_NAME' => 'localhost', 1275 'SERVER_PORT' => 80, 1276 'HTTP_HOST' => 'localhost', 1277 'HTTP_USER_AGENT' => 'Symfony/2.X', 1278 'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 1279 'HTTP_ACCEPT_LANGUAGE' => 'en-us,en;q=0.5', 1280 'HTTP_ACCEPT_CHARSET' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', 1281 'REMOTE_ADDR' => '127.0.0.1', 1282 'SCRIPT_NAME' => '', 1283 'SCRIPT_FILENAME' => '', 1284 ); 1285 $components = parse_url($uri); 1286 if (isset($components['host'])) { 1287 $defaults['SERVER_NAME'] = $components['host']; 1288 $defaults['HTTP_HOST'] = $components['host']; 1289 } 1290 if (isset($components['scheme'])) { 1291 if ('https' === $components['scheme']) { 1292 $defaults['HTTPS'] = 'on'; 1293 $defaults['SERVER_PORT'] = 443; 1294 } 1295 } 1296 if (isset($components['port'])) { 1297 $defaults['SERVER_PORT'] = $components['port']; 1298 $defaults['HTTP_HOST'] = $defaults['HTTP_HOST'].':'.$components['port']; 1299 } 1300 if (in_array(strtoupper($method), array('POST', 'PUT', 'DELETE'))) { 1301 $request = $parameters; 1302 $query = array(); 1303 $defaults['CONTENT_TYPE'] = 'application/x-www-form-urlencoded'; 1304 } else { 1305 $request = array(); 1306 $query = $parameters; 1307 if (false !== $pos = strpos($uri, '?')) { 1308 $qs = substr($uri, $pos + 1); 1309 parse_str($qs, $params); 1310 $query = array_merge($params, $query); 1311 } 1312 } 1313 $queryString = isset($components['query']) ? html_entity_decode($components['query']) : ''; 1314 parse_str($queryString, $qs); 1315 if (is_array($qs)) { 1316 $query = array_replace($qs, $query); 1317 } 1318 $uri = $components['path'] . ($queryString ? '?'.$queryString : ''); 1319 $server = array_replace($defaults, $server, array( 1320 'REQUEST_METHOD' => strtoupper($method), 1321 'PATH_INFO' => '', 1322 'REQUEST_URI' => $uri, 1323 'QUERY_STRING' => $queryString, 1324 )); 1325 return new self($query, $request, array(), $cookies, $files, $server); 1326 } 1327 public function duplicate(array $query = null, array $request = null, array $attributes = null, array $cookies = null, array $files = null, array $server = null) 1328 { 1329 $dup = clone $this; 1330 $dup->initialize( 1331 null !== $query ? $query : $this->query->all(), 1332 null !== $request ? $request : $this->request->all(), 1333 null !== $attributes ? $attributes : $this->attributes->all(), 1334 null !== $cookies ? $cookies : $this->cookies->all(), 1335 null !== $files ? $files : $this->files->all(), 1336 null !== $server ? $server : $this->server->all() 1337 ); 1338 return $dup; 1339 } 1340 public function __clone() 1341 { 1342 $this->query = clone $this->query; 1343 $this->request = clone $this->request; 1344 $this->attributes = clone $this->attributes; 1345 $this->cookies = clone $this->cookies; 1346 $this->files = clone $this->files; 1347 $this->server = clone $this->server; 1348 $this->headers = clone $this->headers; 1349 } 1350 public function overrideGlobals() 1351 { 1352 $_GET = $this->query->all(); 1353 $_POST = $this->request->all(); 1354 $_SERVER = $this->server->all(); 1355 $_COOKIE = $this->cookies->all(); 1356 foreach ($this->headers->all() as $key => $value) { 1357 $_SERVER['HTTP_'.strtoupper(str_replace('-', '_', $key))] = implode(', ', $value); 1358 } 1359 $_REQUEST = array_merge($_GET, $_POST); 1360 } 1361 public function get($key, $default = null) 1362 { 1363 return $this->query->get($key, $this->attributes->get($key, $this->request->get($key, $default))); 1364 } 1365 public function getSession() 1366 { 1367 return $this->session; 1368 } 1369 public function hasSession() 1370 { 1371 return $this->cookies->has(session_name()); 1372 } 1373 public function setSession(Session $session) 1374 { 1375 $this->session = $session; 1376 } 1377 public function getClientIp($proxy = false) 1378 { 1379 if ($proxy) { 1380 if ($this->server->has('HTTP_CLIENT_IP')) { 1381 return $this->server->get('HTTP_CLIENT_IP'); 1382 } elseif ($this->server->has('HTTP_X_FORWARDED_FOR')) { 1383 return $this->server->get('HTTP_X_FORWARDED_FOR'); 1384 } 1385 } 1386 return $this->server->get('REMOTE_ADDR'); 1387 } 1388 public function getScriptName() 1389 { 1390 return $this->server->get('SCRIPT_NAME', $this->server->get('ORIG_SCRIPT_NAME', '')); 1391 } 1392 public function getPathInfo() 1393 { 1394 if (null === $this->pathInfo) { 1395 $this->pathInfo = $this->preparePathInfo(); 1396 } 1397 return $this->pathInfo; 1398 } 1399 public function getBasePath() 1400 { 1401 if (null === $this->basePath) { 1402 $this->basePath = $this->prepareBasePath(); 1403 } 1404 return $this->basePath; 1405 } 1406 public function getBaseUrl() 1407 { 1408 if (null === $this->baseUrl) { 1409 $this->baseUrl = $this->prepareBaseUrl(); 1410 } 1411 return $this->baseUrl; 1412 } 1413 public function getScheme() 1414 { 1415 return ($this->server->get('HTTPS') == 'on') ? 'https' : 'http'; 1416 } 1417 public function getPort() 1418 { 1419 return $this->server->get('SERVER_PORT'); 1420 } 1421 public function getHttpHost() 1422 { 1423 $host = $this->headers->get('HOST'); 1424 if (!empty($host)) { 1425 return $host; 1426 } 1427 $scheme = $this->getScheme(); 1428 $name = $this->server->get('SERVER_NAME'); 1429 $port = $this->getPort(); 1430 if (('http' == $scheme && $port == 80) || ('https' == $scheme && $port == 443)) { 1431 return $name; 1432 } else { 1433 return $name.':'.$port; 1434 } 1435 } 1436 public function getRequestUri() 1437 { 1438 if (null === $this->requestUri) { 1439 $this->requestUri = $this->prepareRequestUri(); 1440 } 1441 return $this->requestUri; 1442 } 1443 public function getUri() 1444 { 1445 $qs = $this->getQueryString(); 1446 if (null !== $qs) { 1447 $qs = '?'.$qs; 1448 } 1449 return $this->getScheme().'://'.$this->getHttpHost().$this->getBaseUrl().$this->getPathInfo().$qs; 1450 } 1451 public function getUriForPath($path) 1452 { 1453 return $this->getScheme().'://'.$this->getHttpHost().$this->getBaseUrl().$path; 1454 } 1455 public function getQueryString() 1456 { 1457 if (!$qs = $this->server->get('QUERY_STRING')) { 1458 return null; 1459 } 1460 $parts = array(); 1461 $order = array(); 1462 foreach (explode('&', $qs) as $segment) { 1463 if (false === strpos($segment, '=')) { 1464 $parts[] = $segment; 1465 $order[] = $segment; 1466 } else { 1467 $tmp = explode('=', urldecode($segment), 2); 1468 $parts[] = urlencode($tmp[0]).'='.urlencode($tmp[1]); 1469 $order[] = $tmp[0]; 1470 } 1471 } 1472 array_multisort($order, SORT_ASC, $parts); 1473 return implode('&', $parts); 1474 } 1475 public function isSecure() 1476 { 1477 return ( 1478 (strtolower($this->server->get('HTTPS')) == 'on' || $this->server->get('HTTPS') == 1) 1479 || 1480 (strtolower($this->headers->get('SSL_HTTPS')) == 'on' || $this->headers->get('SSL_HTTPS') == 1) 1481 || 1482 (strtolower($this->headers->get('X_FORWARDED_PROTO')) == 'https') 1483 ); 1484 } 1485 public function getHost() 1486 { 1487 if ($host = $this->headers->get('X_FORWARDED_HOST')) { 1488 $elements = explode(',', $host); 1489 $host = trim($elements[count($elements) - 1]); 1490 } else { 1491 $host = $this->headers->get('HOST', $this->server->get('SERVER_NAME', $this->server->get('SERVER_ADDR', ''))); 1492 } 1493 $elements = explode(':', $host); 1494 return trim($elements[0]); 1495 } 1496 public function setMethod($method) 1497 { 1498 $this->method = null; 1499 $this->server->set('REQUEST_METHOD', $method); 1500 } 1501 public function getMethod() 1502 { 1503 if (null === $this->method) { 1504 $this->method = strtoupper($this->server->get('REQUEST_METHOD', 'GET')); 1505 if ('POST' === $this->method) { 1506 $this->method = strtoupper($this->request->get('_method', 'POST')); 1507 } 1508 } 1509 return $this->method; 1510 } 1511 public function getMimeType($format) 1512 { 1513 if (null === static::$formats) { 1514 static::initializeFormats(); 1515 } 1516 return isset(static::$formats[$format]) ? static::$formats[$format][0] : null; 1517 } 1518 public function getFormat($mimeType) 1519 { 1520 if (null === static::$formats) { 1521 static::initializeFormats(); 1522 } 1523 foreach (static::$formats as $format => $mimeTypes) { 1524 if (in_array($mimeType, (array) $mimeTypes)) { 1525 return $format; 1526 } 1527 } 1528 return null; 1529 } 1530 public function setFormat($format, $mimeTypes) 1531 { 1532 if (null === static::$formats) { 1533 static::initializeFormats(); 1534 } 1535 static::$formats[$format] = is_array($mimeTypes) ? $mimeTypes : array($mimeTypes); 1536 } 1537 public function getRequestFormat() 1538 { 1539 if (null === $this->format) { 1540 $this->format = $this->get('_format', 'html'); 1541 } 1542 return $this->format; 1543 } 1544 public function setRequestFormat($format) 1545 { 1546 $this->format = $format; 1547 } 1548 public function isMethodSafe() 1549 { 1550 return in_array($this->getMethod(), array('GET', 'HEAD')); 1551 } 1552 public function getContent($asResource = false) 1553 { 1554 if (false === $this->content || (true === $asResource && null !== $this->content)) { 1555 throw new \LogicException('getContent() can only be called once when using the resource return type.'); 1556 } 1557 if (true === $asResource) { 1558 $this->content = false; 1559 return fopen('php://input', 'rb'); 1560 } 1561 if (null === $this->content) { 1562 $this->content = file_get_contents('php://input'); 1563 } 1564 return $this->content; 1565 } 1566 public function getETags() 1567 { 1568 return preg_split('/\s*,\s*/', $this->headers->get('if_none_match'), null, PREG_SPLIT_NO_EMPTY); 1569 } 1570 public function isNoCache() 1571 { 1572 return $this->headers->hasCacheControlDirective('no-cache') || 'no-cache' == $this->headers->get('Pragma'); 1573 } 1574 public function getPreferredLanguage(array $locales = null) 1575 { 1576 $preferredLanguages = $this->getLanguages(); 1577 if (null === $locales) { 1578 return isset($preferredLanguages[0]) ? $preferredLanguages[0] : null; 1579 } 1580 if (!$preferredLanguages) { 1581 return $locales[0]; 1582 } 1583 $preferredLanguages = array_values(array_intersect($preferredLanguages, $locales)); 1584 return isset($preferredLanguages[0]) ? $preferredLanguages[0] : $locales[0]; 1585 } 1586 public function getLanguages() 1587 { 1588 if (null !== $this->languages) { 1589 return $this->languages; 1590 } 1591 $languages = $this->splitHttpAcceptHeader($this->headers->get('Accept-Language')); 1592 foreach ($languages as $lang) { 1593 if (strstr($lang, '-')) { 1594 $codes = explode('-', $lang); 1595 if ($codes[0] == 'i') { 1596 if (count($codes) > 1) { 1597 $lang = $codes[1]; 1598 } 1599 } else { 1600 for ($i = 0, $max = count($codes); $i < $max; $i++) { 1601 if ($i == 0) { 1602 $lang = strtolower($codes[0]); 1603 } else { 1604 $lang .= '_'.strtoupper($codes[$i]); 1605 } 1606 } 1607 } 1608 } 1609 $this->languages[] = $lang; 1610 } 1611 return $this->languages; 1612 } 1613 public function getCharsets() 1614 { 1615 if (null !== $this->charsets) { 1616 return $this->charsets; 1617 } 1618 return $this->charsets = $this->splitHttpAcceptHeader($this->headers->get('Accept-Charset')); 1619 } 1620 public function getAcceptableContentTypes() 1621 { 1622 if (null !== $this->acceptableContentTypes) { 1623 return $this->acceptableContentTypes; 1624 } 1625 return $this->acceptableContentTypes = $this->splitHttpAcceptHeader($this->headers->get('Accept')); 1626 } 1627 public function isXmlHttpRequest() 1628 { 1629 return 'XMLHttpRequest' == $this->headers->get('X-Requested-With'); 1630 } 1631 public function splitHttpAcceptHeader($header) 1632 { 1633 if (!$header) { 1634 return array(); 1635 } 1636 $values = array(); 1637 foreach (array_filter(explode(',', $header)) as $value) { 1638 if ($pos = strpos($value, ';')) { 1639 $q = (float) trim(substr($value, strpos($value, '=') + 1)); 1640 $value = trim(substr($value, 0, $pos)); 1641 } else { 1642 $q = 1; 1643 } 1644 if (0 < $q) { 1645 $values[trim($value)] = $q; 1646 } 1647 } 1648 arsort($values); 1649 return array_keys($values); 1650 } 1651 protected function prepareRequestUri() 1652 { 1653 $requestUri = ''; 1654 if ($this->headers->has('X_REWRITE_URL')) { 1655 $requestUri = $this->headers->get('X_REWRITE_URL'); 1656 } elseif ($this->server->get('IIS_WasUrlRewritten') == '1' && $this->server->get('UNENCODED_URL') != '') { 1657 $requestUri = $this->server->get('UNENCODED_URL'); 1658 } elseif ($this->server->has('REQUEST_URI')) { 1659 $requestUri = $this->server->get('REQUEST_URI'); 1660 $schemeAndHttpHost = $this->getScheme().'://'.$this->getHttpHost(); 1661 if (strpos($requestUri, $schemeAndHttpHost) === 0) { 1662 $requestUri = substr($requestUri, strlen($schemeAndHttpHost)); 1663 } 1664 } elseif ($this->server->has('ORIG_PATH_INFO')) { 1665 $requestUri = $this->server->get('ORIG_PATH_INFO'); 1666 if ($this->server->get('QUERY_STRING')) { 1667 $requestUri .= '?'.$this->server->get('QUERY_STRING'); 1668 } 1669 } 1670 return $requestUri; 1671 } 1672 protected function prepareBaseUrl() 1673 { 1674 $filename = basename($this->server->get('SCRIPT_FILENAME')); 1675 if (basename($this->server->get('SCRIPT_NAME')) === $filename) { 1676 $baseUrl = $this->server->get('SCRIPT_NAME'); 1677 } elseif (basename($this->server->get('PHP_SELF')) === $filename) { 1678 $baseUrl = $this->server->get('PHP_SELF'); 1679 } elseif (basename($this->server->get('ORIG_SCRIPT_NAME')) === $filename) { 1680 $baseUrl = $this->server->get('ORIG_SCRIPT_NAME'); } else { 1681 $path = $this->server->get('PHP_SELF', ''); 1682 $file = $this->server->get('SCRIPT_FILENAME', ''); 1683 $segs = explode('/', trim($file, '/')); 1684 $segs = array_reverse($segs); 1685 $index = 0; 1686 $last = count($segs); 1687 $baseUrl = ''; 1688 do { 1689 $seg = $segs[$index]; 1690 $baseUrl = '/'.$seg.$baseUrl; 1691 ++$index; 1692 } while (($last > $index) && (false !== ($pos = strpos($path, $baseUrl))) && (0 != $pos)); 1693 } 1694 $requestUri = $this->getRequestUri(); 1695 if ($baseUrl && 0 === strpos($requestUri, $baseUrl)) { 1696 return $baseUrl; 1697 } 1698 if ($baseUrl && 0 === strpos($requestUri, dirname($baseUrl))) { 1699 return rtrim(dirname($baseUrl), '/'); 1700 } 1701 $truncatedRequestUri = $requestUri; 1702 if (($pos = strpos($requestUri, '?')) !== false) { 1703 $truncatedRequestUri = substr($requestUri, 0, $pos); 1704 } 1705 $basename = basename($baseUrl); 1706 if (empty($basename) || !strpos($truncatedRequestUri, $basename)) { 1707 return ''; 1708 } 1709 if ((strlen($requestUri) >= strlen($baseUrl)) && ((false !== ($pos = strpos($requestUri, $baseUrl))) && ($pos !== 0))) { 1710 $baseUrl = substr($requestUri, 0, $pos + strlen($baseUrl)); 1711 } 1712 return rtrim($baseUrl, '/'); 1713 } 1714 protected function prepareBasePath() 1715 { 1716 $filename = basename($this->server->get('SCRIPT_FILENAME')); 1717 $baseUrl = $this->getBaseUrl(); 1718 if (empty($baseUrl)) { 1719 return ''; 1720 } 1721 if (basename($baseUrl) === $filename) { 1722 $basePath = dirname($baseUrl); 1723 } else { 1724 $basePath = $baseUrl; 1725 } 1726 if ('\\' === DIRECTORY_SEPARATOR) { 1727 $basePath = str_replace('\\', '/', $basePath); 1728 } 1729 return rtrim($basePath, '/'); 1730 } 1731 protected function preparePathInfo() 1732 { 1733 $baseUrl = $this->getBaseUrl(); 1734 if (null === ($requestUri = $this->getRequestUri())) { 1735 return ''; 1736 } 1737 $pathInfo = ''; 1738 if ($pos = strpos($requestUri, '?')) { 1739 $requestUri = substr($requestUri, 0, $pos); 1740 } 1741 if ((null !== $baseUrl) && (false === ($pathInfo = substr($requestUri, strlen($baseUrl))))) { 1742 return ''; 1743 } elseif (null === $baseUrl) { 1744 return $requestUri; 1745 } 1746 return (string) $pathInfo; 1747 } 1748 static protected function initializeFormats() 1749 { 1750 static::$formats = array( 1751 'txt' => 'text/plain', 1752 'js' => array('application/javascript', 'application/x-javascript', 'text/javascript'), 1753 'css' => 'text/css', 1754 'json' => array('application/json', 'application/x-json'), 1755 'xml' => array('text/xml', 'application/xml', 'application/x-xml'), 1756 'rdf' => 'application/rdf+xml', 1757 'atom' => 'application/atom+xml', 1758 ); 1759 } 1760 } 1761 } 1762 namespace Symfony\Component\HttpFoundation 1763 { 1764 class UniversalClassLoader 1765 { 1766 protected $namespaces = array(); 1767 protected $prefixes = array(); 1768 protected $namespaceFallback; 1769 protected $prefixFallback; 1770 public function getNamespaces() 1771 { 1772 return $this->namespaces; 1773 } 1774 public function getPrefixes() 1775 { 1776 return $this->prefixes; 1777 } 1778 public function getNamespaceFallback() 1779 { 1780 return $this->namespaceFallback; 1781 } 1782 public function getPrefixFallback() 1783 { 1784 return $this->prefixFallback; 1785 } 1786 public function registerNamespaceFallback($dir) 1787 { 1788 $this->namespaceFallback = $dir; 1789 } 1790 public function registerPrefixFallback($dir) 1791 { 1792 $this->prefixFallback = $dir; 1793 } 1794 public function registerNamespaces(array $namespaces) 1795 { 1796 $this->namespaces = array_merge($this->namespaces, $namespaces); 1797 } 1798 public function registerNamespace($namespace, $path) 1799 { 1800 $this->namespaces[$namespace] = $path; 1801 } 1802 public function registerPrefixes(array $classes) 1803 { 1804 $this->prefixes = array_merge($this->prefixes, $classes); 1805 } 1806 public function registerPrefix($prefix, $path) 1807 { 1808 $this->prefixes[$prefix] = $path; 1809 } 1810 public function register() 1811 { 1812 spl_autoload_register(array($this, 'loadClass')); 1813 } 1814 public function loadClass($class) 1815 { 1816 if ('\\' === $class[0]) { 1817 $class = substr($class, 1); 1818 } 1819 if (false !== ($pos = strripos($class, '\\'))) { 1820 $namespace = substr($class, 0, $pos); 1821 foreach ($this->namespaces as $ns => $dir) { 1822 if (0 === strpos($namespace, $ns)) { 1823 $className = substr($class, $pos + 1); 1824 $file = $dir.DIRECTORY_SEPARATOR.str_replace('\\', DIRECTORY_SEPARATOR, $namespace).DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $className).'.php'; 1825 if (file_exists($file)) { 1826 require $file; 1827 return; 1828 } 1829 } 1830 } 1831 if (null !== $this->namespaceFallback) { 1832 $file = $this->namespaceFallback.DIRECTORY_SEPARATOR.str_replace('\\', DIRECTORY_SEPARATOR, $class).'.php'; 1833 if (file_exists($file)) { 1834 require $file; 1835 } 1836 } 1837 } else { 1838 foreach ($this->prefixes as $prefix => $dir) { 1839 if (0 === strpos($class, $prefix)) { 1840 $file = $dir.DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $class).'.php'; 1841 if (file_exists($file)) { 1842 require $file; 1843 return; 1844 } 1845 } 1846 } 1847 if (null !== $this->prefixFallback) { 1848 $file = $this->prefixFallback.DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $class).'.php'; 1849 if (file_exists($file)) { 1850 require $file; 1851 } 1852 } 1853 } 1854 } 1855 } 1856 } branches/2.0/src/Symfony/Component/Routing/Generator/UrlGenerator.php
r31885 r31898 40 40 $this->defaults = $defaults; 41 41 $this->cache = array(); 42 } 43 44 /** 45 * Sets the request context. 46 * 47 * @param array $context The context 48 */ 49 public function setContext(array $context = array()) 50 { 51 $this->context = $context; 42 52 } 43 53 branches/2.0/src/Symfony/Component/Routing/Matcher/ApacheUrlMatcher.php
r31885 r31898 38 38 39 39 /** 40 * Sets the request context. 41 * 42 * @param array $context The context 43 */ 44 public function setContext(array $context = array()) 45 { 46 $this->context = $context; 47 } 48 49 /** 40 50 * Tries to match a URL based on Apache mod_rewrite matching. 41 51 * branches/2.0/src/Symfony/Component/Routing/Matcher/UrlMatcher.php
r31885 r31898 38 38 $this->context = $context; 39 39 $this->defaults = $defaults; 40 } 41 42 /** 43 * Sets the request context. 44 * 45 * @param array $context The context 46 */ 47 public function setContext(array $context = array()) 48 { 49 $this->context = $context; 40 50 } 41 51 branches/2.0/src/Symfony/Component/Routing/Router.php
r31885 r31898 95 95 public function setContext(array $context = array()) 96 96 { 97 $this->context = $context; 98 } 99 100 /** 101 * Sets the defaults. 102 * 103 * @param array $defaults The defaults 104 */ 105 public function setDefaults(array $defaults = array()) 106 { 107 $this->defaults = $defaults; 97 $this->getMatcher()->setContext($context); 98 $this->getGenerator()->setContext($context); 108 99 } 109 100 branches/2.0/tests/Symfony/Tests/Component/DependencyInjection/Compiler/IntegrationTest.php
r31885 r31898 33 33 34 34 $a = $container 35 ->register('a' )35 ->register('a', '\stdClass') 36 36 ->addArgument(new Reference('c')) 37 37 ; 38 38 39 39 $b = $container 40 ->register('b' )40 ->register('b', '\stdClass') 41 41 ->addArgument(new Reference('c')) 42 42 ->setPublic(false) … … 44 44 45 45 $c = $container 46 ->register('c' )46 ->register('c', '\stdClass') 47 47 ->setPublic(false) 48 48 ; … … 62 62 63 63 $a = $container 64 ->register('a' )64 ->register('a', '\stdClass') 65 65 ->addArgument(new Reference('b')) 66 66 ; … … 69 69 70 70 $c = $container 71 ->register('c' )71 ->register('c', '\stdClass') 72 72 ->setPublic(false) 73 73 ; … … 87 87 88 88 $container 89 ->register('a' )89 ->register('a', '\stdClass') 90 90 ->addArgument(new Reference('b')) 91 91 ->addMethodCall('setC', array(new Reference('c'))) … … 93 93 94 94 $container 95 ->register('b' )95 ->register('b', '\stdClass') 96 96 ->addArgument(new Reference('c')) 97 97 ->setPublic(false) … … 99 99 100 100 $container 101 ->register('c' )101 ->register('c', '\stdClass') 102 102 ->setPublic(false) 103 103 ; branches/2.0/tests/Symfony/Tests/Component/DependencyInjection/DefinitionTest.php
r31885 r31898 127 127 128 128 /** 129 * @covers Symfony\Component\DependencyInjection\Definition::setSynthetic 130 * @covers Symfony\Component\DependencyInjection\Definition::isSynthetic 131 */ 132 public function testSetIsSynthetic() 133 { 134 $def = new Definition('stdClass'); 135 $this->assertFalse($def->isSynthetic(), '->isSynthetic() returns false by default'); 136 $this->assertSame($def, $def->setSynthetic(true), '->setSynthetic() implements a fluent interface'); 137 $this->assertTrue($def->isSynthetic(), '->isSynthetic() returns true if the instance must not be public.'); 138 } 139 140 /** 129 141 * @covers Symfony\Component\DependencyInjection\Definition::setConfigurator 130 142 * @covers Symfony\Component\DependencyInjection\Definition::getConfigurator … … 153 165 * @covers Symfony\Component\DependencyInjection\Definition::getTag 154 166 * @covers Symfony\Component\DependencyInjection\Definition::getTags 167 * @covers Symfony\Component\DependencyInjection\Definition::hasTag 155 168 */ 156 169 public function testTags() … … 158 171 $def = new Definition('stdClass'); 159 172 $this->assertEquals(array(), $def->getTag('foo'), '->getTag() returns an empty array if the tag is not defined'); 173 $this->assertFalse($def->hasTag('foo')); 160 174 $this->assertSame($def, $def->addTag('foo'), '->addTag() implements a fluent interface'); 175 $this->assertTrue($def->hasTag('foo')); 161 176 $this->assertEquals(array(array()), $def->getTag('foo'), '->getTag() returns attributes for a tag name'); 162 177 $def->addTag('foo', array('foo' => 'bar')); branches/2.0/tests/Symfony/Tests/Component/HttpFoundation/FileBagTest.php
r31885 r31898 111 111 } 112 112 113 public function testShouldNotConvertNestedUploadedFiles() 114 { 115 $tmpFile = $this->createTempFile(); 116 $file = new UploadedFile($tmpFile, basename($tmpFile), 'text/plain', 100, 0); 117 $bag = new FileBag(array('image' => array('file' => $file))); 118 119 $files = $bag->all(); 120 $this->assertEquals($file, $files['image']['file']); 121 } 122 113 123 protected function createTempFile() 114 124 { branches/2.0/tests/Symfony/Tests/Component/HttpKernel/Cache/EsiListenerTest.php
r31885 r31898 25 25 $dispatcher = new EventDispatcher(); 26 26 $listener = new EsiListener(new Esi()); 27 $ listener->register($dispatcher);27 $dispatcher->connect('core.response', array($listener, 'filter')); 28 28 29 29 $event = new Event(null, 'core.response', array('request_type' => HttpKernelInterface::SUB_REQUEST)); … … 33 33 } 34 34 35 public function testNothingIsRegisteredIfEsiIsNull()36 {37 $dispatcher = new EventDispatcher();38 $listener = new EsiListener();39 $listener->register($dispatcher);40 41 $this->assertEquals(array(), $dispatcher->getListeners('core.response'));42 }43 44 35 public function testFilterWhenThereIsSomeEsiIncludes() 45 36 { 46 37 $dispatcher = new EventDispatcher(); 47 38 $listener = new EsiListener(new Esi()); 48 $ listener->register($dispatcher);39 $dispatcher->connect('core.response', array($listener, 'filter')); 49 40 50 41 $event = new Event(null, 'core.response', array('request_type' => HttpKernelInterface::MASTER_REQUEST)); … … 58 49 $dispatcher = new EventDispatcher(); 59 50 $listener = new EsiListener(new Esi()); 60 $ listener->register($dispatcher);51 $dispatcher->connect('core.response', array($listener, 'filter')); 61 52 62 53 $event = new Event(null, 'core.response', array('request_type' => HttpKernelInterface::MASTER_REQUEST)); branches/2.0/tests/Symfony/Tests/Component/HttpKernel/ResponseListenerTest.php
r31403 r31898 61 61 $dispatcher = new EventDispatcher(); 62 62 $listener = new ResponseListener(); 63 $ listener->register($dispatcher);63 $dispatcher->connect('core.response', array($listener, 'filter')); 64 64 65 65 return $dispatcher;