Development

Changeset 31898

You must first sign up to be able to contribute.

Changeset 31898

Show
Ignore:
Timestamp:
01/25/11 09:45:06 (2 years ago)
Author:
fabien
Message:

Merge branch 'master' of git://github.com/symfony/symfony

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/2.0/src/Symfony/Bundle/CompatAssetsBundle/Templating/Helper/JavascriptsHelper.php

    r31885 r31898  
    8484 
    8585    /** 
    86      * Outputs HTML representation of the links to JavaScripts. 
    87      * 
    88      */ 
    89     public function output() 
    90     { 
    91         echo $this->render(); 
    92     } 
    93  
    94     /** 
    9586     * Returns a string representation of this helper as HTML. 
    9687     * 
  • branches/2.0/src/Symfony/Bundle/CompatAssetsBundle/Templating/Helper/StylesheetsHelper.php

    r31885 r31898  
    8484 
    8585    /** 
    86      * Outputs HTML representation of the links to stylesheets. 
    87      * 
    88      */ 
    89     public function output() 
    90     { 
    91         echo $this->render(); 
    92     } 
    93  
    94     /** 
    9586     * Returns a string representation of this helper as HTML. 
    9687     * 
  • branches/2.0/src/Symfony/Bundle/DoctrineBundle/DependencyInjection/DoctrineExtension.php

    • Property svn:executable set to *
    r31885 r31898  
    282282            } 
    283283            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']; 
    285285            } 
    286286            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']; 
    288288            } 
    289289        } 
  • branches/2.0/src/Symfony/Bundle/DoctrineBundle/Resources/config/orm.xml

    r31885 r31898  
    3131        <parameter key="doctrine.orm.metadata.annotation_class">Doctrine\ORM\Mapping\Driver\AnnotationDriver</parameter> 
    3232        <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> 
    3433        <parameter key="doctrine.orm.metadata.xml_class">Doctrine\ORM\Mapping\Driver\XmlDriver</parameter> 
    3534        <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  
    2424        $kernel = $this->getMock('Symfony\Component\HttpKernel\Kernel', array(), array(), '', false); 
    2525        $kernel->expects($this->once()) 
    26                ->method('isBooted') 
    27                ->will($this->returnValue( true )); 
    28         $kernel->expects($this->once()) 
    2926               ->method('getBundles') 
    3027               ->will($this->returnValue(array())); 
  • branches/2.0/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php

    • Property svn:executable set to *
    r31885 r31898  
    134134        $this->assertEquals('Doctrine\ORM\Mapping\Driver\AnnotationDriver', $container->getParameter('doctrine.orm.metadata.annotation_class')); 
    135135        $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')); 
    137136        $this->assertEquals('Doctrine\ORM\Mapping\Driver\XmlDriver', $container->getParameter('doctrine.orm.metadata.xml_class')); 
    138137        $this->assertEquals('Doctrine\ORM\Mapping\Driver\YamlDriver', $container->getParameter('doctrine.orm.metadata.yml_class')); 
     
    426425    } 
    427426 
    428     public function testMultipleOrmLoadCalls() 
     427    public function testOrmMergeConfigs() 
    429428    { 
    430429        $container = $this->getContainer(array('XmlBundle', 'AnnotationsBundle')); 
     
    433432        $loader->dbalLoad(array(array()), $container); 
    434433        $loader->ormLoad(array(array( 
    435                 'auto_generate_proxy_dir' => true, 
     434                'auto_generate_proxy_classes' => true, 
    436435                'mappings' => array('AnnotationsBundle' => array()) 
    437436            ), 
    438437            array( 
    439                 'auto_generate_proxy_dir' => false, 
     438                'auto_generate_proxy_classes' => false, 
    440439                'mappings' => array('XmlBundle' => array()) 
    441440        )), $container); 
     
    452451 
    453452        $configDef = $container->getDefinition('doctrine.orm.default_configuration'); 
    454         $this->assertDICDefinitionMethodCallOnce($configDef, 'setAutoGenerateProxyClasses', array(false)); 
     453        $this->assertDICDefinitionMethodCallOnce($configDef, 'setAutoGenerateProxyClasses', array( false )); 
    455454    } 
    456455 
     
    515514 
    516515        $configDefinition = $container->getDefinition('doctrine.orm.default_configuration'); 
    517         $this->assertDICDefinitionMethodCallOnce($configDefinition, 'setAutoGenerateProxyClasses', array(false)); 
     516        $this->assertDICDefinitionMethodCallOnce($configDefinition, 'setAutoGenerateProxyClasses', array(true)); 
    518517    } 
    519518 
  • branches/2.0/src/Symfony/Bundle/DoctrineMigrationsBundle/Command/DoctrineCommand.php

    r31885 r31898  
    2828        $configuration->setMigrationsNamespace($bundle.'\DoctrineMigrations'); 
    2929 
    30         $bundle = $this->application->getKernel()->getBundle($input->getArgument('bundle')); 
     30        $bundle = $application->getKernel()->getBundle($bundle); 
    3131        $dir = $bundle->getPath().'/DoctrineMigrations'; 
    3232 
    3333        $configuration->setMigrationsDirectory($dir); 
    3434        $configuration->registerMigrationsFromDirectory($dir); 
    35         $configuration->setName($bundle.' Migrations'); 
     35        $configuration->setName($bundle->getName().' Migrations'); 
    3636        $configuration->setMigrationsTableName(Inflector::tableize($bundle->getName()).'_migration_versions'); 
    3737    } 
  • branches/2.0/src/Symfony/Bundle/DoctrineMongoDBBundle/Command/LoadDataFixturesDoctrineODMCommand.php

    r31885 r31898  
    7373        } 
    7474 
     75        $paths = array_filter($paths, 'is_dir'); 
     76 
    7577        $loader = new \Doctrine\Common\DataFixtures\Loader(); 
    7678        foreach ($paths as $path) { 
  • branches/2.0/src/Symfony/Bundle/DoctrineMongoDBBundle/DependencyInjection/DoctrineMongoDBExtension.php

    r31885 r31898  
    7373            'default_document_manager', 
    7474            'default_connection', 
    75             'cache_driver', 
    7675            'metadata_cache_driver', 
    7776            'proxy_namespace', 
  • branches/2.0/src/Symfony/Bundle/DoctrineMongoDBBundle/Resources/config/mongodb.xml

    r31885 r31898  
    2323 
    2424    <!-- hydrators --> 
    25     <parameter key="doctrine.odm.mongodb.hydrator_namespace">Proxies</parameter> 
     25    <parameter key="doctrine.odm.mongodb.hydrator_namespace">Hydrators</parameter> 
    2626    <parameter key="doctrine.odm.mongodb.hydrator_dir">%kernel.cache_dir%/doctrine/odm/mongodb/Hydrators</parameter> 
    2727    <parameter key="doctrine.odm.mongodb.auto_generate_hydrator_classes">false</parameter> 
     
    4040    <parameter key="doctrine.odm.mongodb.metadata.annotation_class">Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver</parameter> 
    4141    <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> 
    4342    <parameter key="doctrine.odm.mongodb.metadata.xml_class">Doctrine\ODM\MongoDB\Mapping\Driver\XmlDriver</parameter> 
    4443    <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  
    5252        $this->assertInstanceOf('Doctrine\Common\Cache\ArrayCache', $container->get('doctrine.odm.mongodb.cache')); 
    5353        $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')); 
    5554        $this->assertInstanceof('Doctrine\Common\EventManager', $container->get('doctrine.odm.mongodb.event_manager')); 
    5655    } 
  • branches/2.0/src/Symfony/Bundle/DoctrineMongoDBBundle/Tests/DependencyInjection/AbstractMongoDBExtensionTest.php

    r31885 r31898  
    4646        $this->assertEquals('Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver', $container->getParameter('doctrine.odm.mongodb.metadata.annotation_class')); 
    4747        $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')); 
    4948        $this->assertEquals('Doctrine\ODM\MongoDB\Mapping\Driver\XmlDriver', $container->getParameter('doctrine.odm.mongodb.metadata.xml_class')); 
    5049        $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  
    4949    protected function forward(Request $request, $raw = false, Response $entry = null) 
    5050    { 
    51         if (!$this->kernel->isBooted()) { 
    52             $this->kernel->boot(); 
    53         } 
     51        $this->kernel->boot(); 
    5452        $this->kernel->getContainer()->set('cache', $this); 
    5553        $this->kernel->getContainer()->set('esi', $this->esi); 
  • branches/2.0/src/Symfony/Bundle/FrameworkBundle/Console/Application.php

    r31885 r31898  
    3838        $this->definition->addOption(new InputOption('--shell', '-s', InputOption::VALUE_NONE, 'Launch the shell.')); 
    3939 
    40         if (!$this->kernel->isBooted()) { 
    41             $this->kernel->boot(); 
    42         } 
     40        $this->kernel->boot(); 
    4341 
    4442        $this->registerCommands(); 
  • branches/2.0/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php

    r31885 r31898  
    7070    public function forward($controller, array $path = array(), array $query = array()) 
    7171    { 
    72         return $this->container->get('controller_resolver')->forward($controller, $path, $query); 
     72        return $this->container->get('http_kernel')->forward($controller, $path, $query); 
    7373    } 
    7474 
  • branches/2.0/src/Symfony/Bundle/FrameworkBundle/Controller/ParamConverterListener.php

    r31885 r31898  
    2424 * (Typehinted). 
    2525 * 
     26 * The filterController method must be connected to the core.controller event. 
     27 * 
    2628 * @author Fabien Potencier <fabien.potencier@symfony-project.org> 
    2729 * @author Henrik Bjornskov <hb@peytz.dk> 
     
    4042    { 
    4143        $this->manager = $manager; 
    42     } 
    43  
    44     /** 
    45      * @param EventDispatcher $dispatcher 
    46      * @param integer         $priority = 0 
    47      */ 
    48     public function register(EventDispatcher $dispatcher, $priority = 0) 
    49     { 
    50         $dispatcher->connect('core.controller', array($this, 'filterController'), $priority); 
    5144    } 
    5245 
  • branches/2.0/src/Symfony/Bundle/FrameworkBundle/Debug/EventDispatcher.php

    r31885 r31898  
    1717use Symfony\Component\HttpKernel\Log\LoggerInterface; 
    1818use Symfony\Component\HttpKernel\Debug\EventDispatcherTraceableInterface; 
     19use Symfony\Component\DependencyInjection\ContainerInterface; 
    1920 
    2021/** 
     
    3132     * Constructor. 
    3233     * 
    33      * @param LoggerInterface $logger A LoggerInterface instance 
     34     * @param ContainerInterface $container A ContainerInterface instance 
     35     * @param LoggerInterface    $logger    A LoggerInterface instance 
    3436     */ 
    35     public function __construct(LoggerInterface $logger = null) 
     37    public function __construct(ContainerInterface $container, LoggerInterface $logger = null) 
    3638    { 
     39        parent::__construct($container); 
     40 
    3741        $this->logger = $logger; 
    3842        $this->called = array(); 
     
    4549    { 
    4650        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 
    4755            $this->addCall($event, $listener, 'notify'); 
    4856 
     
    5967    { 
    6068        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 
    6173            $this->addCall($event, $listener, 'notifyUntil'); 
    6274 
     
    8597    { 
    8698        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 
    87103            $this->addCall($event, $listener, 'filter'); 
    88104 
     
    112128        foreach (array_keys($this->listeners) as $name) { 
    113129            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 
    114134                $listener = $this->listenerToString($listener); 
    115135 
  • branches/2.0/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/RegisterKernelListenersPass.php

    r31885 r31898  
    2525 
    2626        $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                } 
    2936 
    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']); 
    3245            } 
    33  
    34             $listeners[$priority][] = new Reference($id); 
    3546        } 
    3647 
  • branches/2.0/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/TemplatingPass.php

    r31885 r31898  
    3232            } 
    3333 
    34             $definition = $container->getDefinition('templating.engine.php'); 
    35             $arguments = $definition->getArguments(); 
    36             $definition->setArguments($arguments); 
    37  
    3834            if (count($helpers) > 0) { 
     35                $definition = $container->getDefinition('templating.engine.php'); 
    3936                $definition->addMethodCall('setHelpers', array($helpers)); 
    4037            } 
    4138        } 
    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         } 
    5739    } 
    5840} 
  • branches/2.0/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

    r31885 r31898  
    158158        } 
    159159 
     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 
    160167        $this->addClassesToCompile(array( 
    161168            'Symfony\\Component\\HttpFoundation\\ParameterBag', 
     
    206213        $config = isset($config['templating']) ? $config['templating'] : array(); 
    207214 
    208         if (!$container->hasDefinition('templating')) { 
     215        if (!$container->hasDefinition('templating.locator')) { 
    209216            $loader = new XmlFileLoader($container, __DIR__.'/../Resources/config'); 
    210217            $loader->load('templating.xml'); 
     218            $loader->load('templating_php.xml'); 
    211219 
    212220            if ($container->getParameter('kernel.debug')) { 
     
    229237        if (array_key_exists('assets_base_urls', $config)) { 
    230238            $container->setParameter('templating.assets.base_urls', $config['assets_base_urls']); 
    231         } 
    232  
    233         // path for the filesystem loader 
    234         if (isset($config['path'])) { 
    235             $container->setParameter('templating.loader.filesystem.path', $config['path']); 
    236239        } 
    237240 
     
    261264        } 
    262265 
    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 
    264293        $this->addClassesToCompile(array( 
    265             'Symfony\\Component\\Templating\\DelegatingEngine', 
    266294            'Symfony\\Bundle\\FrameworkBundle\\Templating\\EngineInterface', 
    267295            'Symfony\\Component\\Templating\\EngineInterface', 
     296            'Symfony\\Bundle\\FrameworkBundle\\Templating\\Loader\\TemplateLocatorInterface', 
     297            $container->findDefinition('templating.locator')->getClass(), 
    268298        )); 
    269299    } 
     
    436466        $container->setParameter('routing.resource', $config['router']['resource']); 
    437467 
     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 
    438477        $this->addClassesToCompile(array( 
    439478            'Symfony\\Component\\Routing\\RouterInterface', 
    440             'Symfony\\Component\\Routing\\Router', 
    441479            'Symfony\\Component\\Routing\\Matcher\\UrlMatcherInterface', 
    442480            'Symfony\\Component\\Routing\\Matcher\\UrlMatcher', 
    443481            'Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface', 
    444482            'Symfony\\Component\\Routing\\Generator\\UrlGenerator', 
    445             'Symfony\\Component\\Routing\\Loader\\LoaderInterface', 
    446             'Symfony\\Bundle\\FrameworkBundle\\Routing\\LazyLoader', 
     483            $container->findDefinition('router')->getClass() 
    447484        )); 
    448485    } 
  • branches/2.0/src/Symfony/Bundle/FrameworkBundle/EventDispatcher.php

    r31885 r31898  
    1313 
    1414use Symfony\Component\EventDispatcher\EventDispatcher as BaseEventDispatcher; 
     15use Symfony\Component\DependencyInjection\ContainerInterface; 
     16use Symfony\Component\EventDispatcher\Event; 
    1517 
    1618/** 
     
    2123class EventDispatcher extends BaseEventDispatcher 
    2224{ 
    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) 
    2433    { 
    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; 
    2869            } 
    2970        } 
     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; 
    3090    } 
    3191} 
  • branches/2.0/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php

    r31885 r31898  
    2222use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddClassesToCachePass; 
    2323use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslatorPass; 
     24use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddCacheWarmerPass; 
    2425use Symfony\Component\DependencyInjection\ContainerBuilder; 
    2526use Symfony\Component\DependencyInjection\Compiler\PassConfig; 
     
    8384        $container->addCompilerPass(new AddClassesToCachePass()); 
    8485        $container->addCompilerPass(new TranslatorPass()); 
     86        $container->addCompilerPass(new AddCacheWarmerPass()); 
    8587    } 
    8688 
  • branches/2.0/src/Symfony/Bundle/FrameworkBundle/RequestListener.php

    r31885 r31898  
    2222 * RequestListener. 
    2323 * 
     24 * The handle method must be connected to the core.request event. 
     25 * 
    2426 * @author Fabien Potencier <fabien.potencier@symfony-project.com> 
    2527 */ 
     
    3537        $this->router = $router; 
    3638        $this->logger = $logger; 
    37     } 
    38  
    39     /** 
    40      * Registers a core.request listener. 
    41      * 
    42      * @param EventDispatcher $dispatcher An EventDispatcher instance 
    43      * @param integer         $priority   The priority 
    44      */ 
    45     public function register(EventDispatcher $dispatcher, $priority = 0) 
    46     { 
    47         $dispatcher->connect('core.request', array($this, 'handle'), $priority); 
    4839    } 
    4940 
  • branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug.xml

    r31780 r31898  
    1111    <services> 
    1212        <service id="debug.event_dispatcher" class="%debug.event_dispatcher.class%"> 
     13            <argument type="service" id="service_container" /> 
    1314            <argument type="service" id="logger" on-invalid="null" /> 
    1415        </service> 
  • branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/config/esi.xml

    r31885 r31898  
    1313        <service id="esi" class="%esi.class%" public="false" /> 
    1414 
    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" /> 
    1717          <argument type="service" id="esi" on-invalid="ignore" /> 
    1818        </service> 
  • branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/config/param_converter.xml

    r31780 r31898  
    1515 
    1616        <!-- 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" /> 
    1919            <argument type="service" id="request.param_converter.manager" /> 
    2020        </service> 
  • branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/config/profiling.xml

    r31780 r31898  
    2525        </service> 
    2626 
    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" /> 
    2930            <argument type="service" id="profiler" /> 
    3031            <argument type="service" id="profiler.request_matcher" on-invalid="null" /> 
  • branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing.xml

    r31885 r31898  
    77    <parameters> 
    88        <parameter key="router.class">Symfony\Component\Routing\Router</parameter> 
     9        <parameter key="router.cached.class">Symfony\Bundle\FrameworkBundle\Routing\CachedRouter</parameter> 
    910        <parameter key="routing.loader.class">Symfony\Bundle\FrameworkBundle\Routing\DelegatingLoader</parameter> 
    1011        <parameter key="routing.file_locator.class">Symfony\Bundle\FrameworkBundle\Routing\FileLocator</parameter> 
     
    1920        <parameter key="router.options.matcher_base_class">Symfony\Component\Routing\Matcher\UrlMatcher</parameter> 
    2021        <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> 
    2123    </parameters> 
    2224 
     
    5456        </service> 
    5557 
    56         <service id="router" class="%router.class%"> 
     58        <service id="router.real" class="%router.class%"> 
    5759            <argument type="service" id="routing.loader" /> 
    5860            <argument>%routing.resource%</argument> 
     
    7072            </argument> 
    7173        </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> 
    7287    </services> 
    7388</container> 
  • branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd

    r31885 r31898  
    2424        <xsd:attribute name="charset" type="xsd:string" /> 
    2525        <xsd:attribute name="error-handler" type="xsd:string" /> 
     26        <xsd:attribute name="cache-warmer" type="cache_warmer" /> 
    2627    </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> 
    2736 
    2837    <xsd:complexType name="profiler"> 
     
    4150        <xsd:attribute name="resource" type="xsd:string" /> 
    4251        <xsd:attribute name="type" type="xsd:string" /> 
     52        <xsd:attribute name="cache-warmer" type="cache_warmer" /> 
    4353    </xsd:complexType> 
    4454 
     
    6474 
    6575    <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> 
    6980 
    7081        <xsd:attribute name="assets-version" type="xsd:string" /> 
    7182        <xsd:attribute name="assets-base-urls" type="xsd:string" /> 
    72         <xsd:attribute name="path" type="xsd:string" /> 
    7383        <xsd:attribute name="cache" type="xsd:string" /> 
     84        <xsd:attribute name="cache-warmer" type="cache_warmer" /> 
    7485    </xsd:complexType> 
    7586 
     
    90101        <xsd:attribute name="enabled" type="xsd:boolean" /> 
    91102    </xsd:complexType> 
     103 
     104    <xsd:complexType name="templating_engine"> 
     105        <xsd:attribute name="id" type="xsd:string" /> 
     106    </xsd:complexType> 
    92107</xsd:schema> 
  • branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/config/security.xml

    r31885 r31898  
    155155        </service> 
    156156 
    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" /> 
    159159            <argument type="service" id="security.firewall.map" /> 
     160            <argument type="service" id="event_dispatcher" /> 
    160161        </service> 
     162 
    161163        <service id="security.firewall.map" class="%security.firewall.map.class%" public="false"> 
    162164            <argument type="service" id="service_container" /> 
    163165            <argument type="collection" /> 
    164166        </service> 
    165          
     167 
    166168        <service id="security.context_listener" class="%security.context_listener.class%" public="false"> 
    167169            <argument type="service" id="security.context" /> 
  • branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml

    r31885 r31898  
    1212        <parameter key="error_handler.level">null</parameter> 
    1313        <parameter key="filesystem.class">Symfony\Bundle\FrameworkBundle\Util\Filesystem</parameter> 
     14        <parameter key="cache_warmer.class">Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate</parameter> 
    1415    </parameters> 
    1516 
    1617    <services> 
    1718        <service id="event_dispatcher" class="%event_dispatcher.class%"> 
     19            <argument type="service" id="service_container" /> 
    1820        </service> 
    1921 
     
    2830        </service> 
    2931 
     32        <service id="cache_warmer" class="%cache_warmer.class%"> 
     33            <argument type="collection" /> 
     34        </service> 
     35 
    3036        <!-- 
    3137            If you want to change the Request class, modify the code in 
     
    3541            It is used to check references scope. 
    3642        --> 
    37         <service id="request" scope="request" /> 
     43        <service id="request" scope="request" synthetic="true" /> 
    3844 
    3945        <service id="response" class="%response.class%" scope="prototype"> 
  • branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating.xml

    r31885 r31898  
    77    <parameters> 
    88        <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> 
    109        <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> 
    1111        <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> 
    1213        <parameter key="templating.loader.filesystem.class">Symfony\Bundle\FrameworkBundle\Templating\Loader\FilesystemLoader</parameter> 
    1314        <parameter key="templating.loader.cache.class">Symfony\Component\Templating\Loader\CacheLoader</parameter> 
    1415        <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> 
    2516        <parameter key="templating.assets.version">null</parameter> 
    2617        <parameter key="templating.assets.base_urls" type="collection"></parameter> 
    27         <parameter key="templating.renderer.php.class">Symfony\Component\Templating\Renderer\PhpRenderer</parameter> 
    2818        <parameter key="debug.file_link_format">null</parameter> 
    2919    </parameters> 
     
    3222        <service id="templating.engine.delegating" class="%templating.engine.delegating.class%" public="false"> 
    3323            <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" /> 
    4125        </service> 
    4226 
     
    4933            <argument type="service" id="templating.name_parser" /> 
    5034            <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> 
    5144        </service> 
    5245 
     
    6558        </service> 
    6659 
    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  
    11960        <service id="templating.loader" alias="templating.loader.filesystem" /> 
    120  
    121         <service id="templating" alias="templating.engine.delegating" /> 
    12261    </services> 
    12362</container> 
  • branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/config/web.xml

    r31885 r31898  
    2626        </service> 
    2727 
    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" /> 
    3030            <argument type="service" id="service_container" /> 
    3131            <argument type="service" id="router" /> 
     
    3333        </service> 
    3434 
    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" /> 
    3737        </service> 
    3838 
    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" /> 
    4141            <argument>%exception_listener.controller%</argument> 
    4242            <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  
    44{% for e in exception.toarray %} 
    55    <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 %} 
    77    </exception> 
    88{% endfor %} 
  • branches/2.0/src/Symfony/Bundle/FrameworkBundle/Templating/DelegatingEngine.php

    r31885 r31898  
    3131     * @param ContainerInterface $container The DI container 
    3232     */ 
    33     public function __construct(ContainerInterface $container
     33    public function __construct(ContainerInterface $container, array $engineIds
    3434    { 
    3535        $this->container = $container; 
    36         $this->engines = array(); 
    37     } 
    38  
    39     public function setEngineIds($ids) 
    40     { 
    41         $this->engines = $ids; 
     36        $this->engines = $engineIds; 
    4237    } 
    4338 
  • branches/2.0/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/ActionsHelper.php

    r31885 r31898  
    3535 
    3636    /** 
    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 URI 
    40      * @param array  $options    An array of options 
    41      * 
    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     /** 
    5037     * Returns the Response content for a given controller or URI. 
    5138     * 
  • branches/2.0/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php

    r31885 r31898  
    6464        $cli = implode(' ', $_SERVER['argv']); 
    6565        if (preg_match('/\-\-configuration[= ]+([^ ]+)/', $cli, $matches)) { 
    66             $dir = $dir.'/'.$matches[1]
     66            $dir = realpath($matches[1])
    6767        } elseif (preg_match('/\-c +([^ ]+)/', $cli, $matches)) { 
    68             $dir = $dir.'/'.$matches[1]
     68            $dir = realpath($matches[1])
    6969        } elseif (file_exists(getcwd().'/phpunit.xml') || file_exists(getcwd().'/phpunit.xml.dist')) { 
    7070            $dir = getcwd(); 
  • branches/2.0/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

    r31885 r31898  
    3535 
    3636        // templating 
    37         $loader->configLoad(array(array('templating' => array())), $container); 
     37        $loader->configLoad(array(array('templating' => array('engines' => array('php')))), $container); 
    3838        $this->assertEquals('Symfony\\Bundle\\FrameworkBundle\\Templating\\PhpEngine', $container->getParameter('templating.engine.php.class'), '->templatingLoad() loads the templating.xml file if not already loaded'); 
    3939 
  • branches/2.0/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php

    r31885 r31898  
    109109        } 
    110110 
     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 
    111119        $container->setParameter('twig.options', array_replace($container->getParameter('twig.options'), $config)); 
    112120    } 
  • branches/2.0/src/Symfony/Bundle/TwigBundle/Resources/config/schema/twig-1.0.xsd

    r31885 r31898  
    2222        <xsd:attribute name="base-template-class" type="xsd:string" /> 
    2323        <xsd:attribute name="autoescape" type="xsd:string" /> 
     24        <xsd:attribute name="cache-warmer" type="cache_warmer" /> 
    2425    </xsd:complexType> 
    2526 
     
    3940        <xsd:attribute name="id" type="xsd:string" /> 
    4041    </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> 
    4150</xsd:schema> 
  • branches/2.0/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml

    r31885 r31898  
    1818        </parameter> 
    1919        <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> 
    2021    </parameters> 
    2122 
     
    2627        </service> 
    2728 
     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 
    2833        <service id="twig.loader" class="%twig.loader.class%"> 
    2934            <argument type="service" id="templating.locator" /> 
    3035        </service> 
    3136 
    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"> 
    3438            <argument type="service" id="service_container" /> 
    3539            <argument type="service" id="twig" /> 
  • branches/2.0/src/Symfony/Bundle/WebProfilerBundle/Resources/config/toolbar.xml

    r31885 r31898  
    1111 
    1212    <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" /> 
    1515            <argument type="service" id="http_kernel" /> 
    1616            <argument>%debug.toolbar.intercept_redirects%</argument> 
  • branches/2.0/src/Symfony/Bundle/WebProfilerBundle/WebDebugToolbarListener.php

    r31885 r31898  
    2222 * WebDebugToolbarListener injects the Web Debug Toolbar. 
    2323 * 
     24 * The handle method must be connected to the core.response event. 
     25 * 
    2426 * @author Fabien Potencier <fabien.potencier@symfony-project.com> 
    2527 */ 
     
    3335        $this->kernel = $kernel; 
    3436        $this->interceptRedirects = $interceptRedirects; 
    35     } 
    36  
    37     /** 
    38      * Registers a core.response listener. 
    39      * 
    40      * @param EventDispatcher $dispatcher An EventDispatcher instance 
    41      * @param integer         $priority   The priority 
    42      */ 
    43     public function register(EventDispatcher $dispatcher, $priority = 0) 
    44     { 
    45         $dispatcher->connect('core.response', array($this, 'handle'), $priority); 
    4637    } 
    4738 
  • branches/2.0/src/Symfony/Component/Console/Output/StreamOutput.php

    r31885 r31898  
    8080        } 
    8181 
    82         flush(); 
     82        fflush($this->stream); 
    8383    } 
    8484 
  • branches/2.0/src/Symfony/Component/DependencyInjection/Compiler/CheckReferenceScopePass.php

    r31885 r31898  
    4545 
    4646        foreach ($container->getDefinitions() as $id => $definition) { 
     47            if ($definition->isSynthetic()) { 
     48                continue; 
     49            } 
     50 
    4751            $this->currentId = $id; 
    4852            $this->currentScope = $scope = $definition->getScope(); 
  • branches/2.0/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php

    r31885 r31898  
    4444        $this->optimizationPasses = array( 
    4545            new ResolveParameterPlaceHoldersPass(), 
     46            new CheckDefinitionValidityPass(), 
    4647            new ResolveReferencesToAliasesPass(), 
    4748            new ResolveInterfaceInjectorsPass(), 
  • branches/2.0/src/Symfony/Component/DependencyInjection/Compiler/ResolveInterfaceInjectorsPass.php

    r31885 r31898  
    2727    { 
    2828        foreach ($container->getDefinitions() as $definition) { 
     29            if ($definition->isSynthetic()) { 
     30                continue; 
     31            } 
     32 
    2933            $loaded = false; 
    3034            foreach ($container->getInterfaceInjectors() as $injector) { 
  • branches/2.0/src/Symfony/Component/DependencyInjection/Compiler/ResolveInvalidReferencesPass.php

    r31885 r31898  
    4141        $this->container = $container; 
    4242        foreach ($container->getDefinitions() as $definition) { 
     43            if ($definition->isSynthetic()) { 
     44                continue; 
     45            } 
     46 
    4347            $definition->setArguments( 
    4448                $this->processArguments($definition->getArguments()) 
  • branches/2.0/src/Symfony/Component/DependencyInjection/Compiler/ResolveReferencesToAliasesPass.php

    r31885 r31898  
    6262    protected function getDefinitionId($id) 
    6363    { 
    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); 
    6666        } 
    6767 
  • branches/2.0/src/Symfony/Component/DependencyInjection/Definition.php

    r31885 r31898  
    2929    protected $tags; 
    3030    protected $public; 
     31    protected $synthetic; 
    3132 
    3233    /** 
     
    4445        $this->tags = array(); 
    4546        $this->public = true; 
     47        $this->synthetic = false; 
    4648    } 
    4749 
     
    296298 
    297299    /** 
     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    /** 
    298312     * Clears the tags for this definition. 
    299313     * 
     
    379393 
    380394    /** 
     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    /** 
    381421     * Sets a configurator to call after the service is fully initialized. 
    382422     * 
  • branches/2.0/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php

    r31885 r31898  
    395395 
    396396        $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()) { 
    398400            $return = sprintf("@return %s A %s instance.", 0 === strpos($class, '%') ? 'Object' : $class, $class); 
    399401        } elseif ($definition->getFactoryService()) { 
     
    444446        } 
    445447 
    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        } 
    456462 
    457463        $this->definitionVariables = null; 
  • branches/2.0/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php

    r31885 r31898  
    1313 
    1414use Symfony\Component\DependencyInjection\ContainerInterface; 
    15  
    1615use Symfony\Component\DependencyInjection\Alias; 
    17  
    1816use Symfony\Component\DependencyInjection\InterfaceInjector; 
    1917use Symfony\Component\DependencyInjection\Definition; 
     
    140138        $definition = new Definition(); 
    141139 
    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) { 
    143141            if (isset($service[$key])) { 
    144142                $method = 'set'.str_replace('-', '', $key); 
  • branches/2.0/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php

    r31885 r31898  
    1313 
    1414use Symfony\Component\DependencyInjection\Alias; 
    15  
    1615use Symfony\Component\DependencyInjection\ContainerInterface; 
    1716use Symfony\Component\DependencyInjection\InterfaceInjector; 
     
    149148        } 
    150149 
     150        if (isset($service['synthetic'])) { 
     151            $definition->setSynthetic($service['synthetic']); 
     152        } 
     153 
    151154        if (isset($service['public'])) { 
    152155            $definition->setPublic($service['public']); 
  • branches/2.0/src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd

    r31885 r31898  
    104104    <xsd:attribute name="scope" type="xsd:string" /> 
    105105    <xsd:attribute name="public" type="boolean" /> 
     106    <xsd:attribute name="synthetic" type="boolean" /> 
    106107    <xsd:attribute name="factory-method" type="xsd:string" /> 
    107108    <xsd:attribute name="factory-service" type="xsd:string" /> 
  • branches/2.0/src/Symfony/Component/DependencyInjection/ParameterBag/FrozenParameterBag.php

    r31885 r31898  
    2121     * Constructor. 
    2222     * 
     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     * 
    2328     * @param array $parameters An array of parameters 
    2429     */ 
    2530    public function __construct(array $parameters = array()) 
    2631    { 
    27         foreach ($parameters as $key => $value) { 
    28             $this->parameters[strtolower($key)] = $value; 
    29         } 
     32        $this->parameters = $parameters; 
    3033    } 
    3134 
     35    /** 
     36     * {@inheritdoc} 
     37     */ 
    3238    public function clear() 
    3339    { 
     
    3642 
    3743    /** 
    38      * Adds parameters to the service container parameters. 
    39      * 
    40      * @param array $parameters An array of parameters 
     44     * {@inheritdoc} 
    4145     */ 
    4246    public function add(array $parameters) 
     
    4650 
    4751    /** 
    48      * Sets a service container parameter. 
    49      * 
    50      * @param string $name       The parameter name 
    51      * @param mixed  $parameters The parameter value 
     52     * {@inheritdoc} 
    5253     */ 
    5354    public function set($name, $value) 
  • branches/2.0/src/Symfony/Component/EventDispatcher/EventDispatcher.php

    r31885 r31898  
    4949     * @param string $name An event name 
    5050     * @param mixed|null $listener the listener to remove, or null to remove all 
     51     * 
    5152     * @return void 
    5253     */ 
     
    5455    { 
    5556        if (!isset($this->listeners[$name])) { 
    56             return false
     57            return
    5758        } 
    5859 
  • branches/2.0/src/Symfony/Component/HttpFoundation/FileBag.php

    r31885 r31898  
    4040    public function set($key, $value) 
    4141    { 
    42         if (is_array($value)) { 
     42        if (is_array($value) || $value instanceof UploadedFile) { 
    4343            parent::set($key, $this->convertFileInformation($value)); 
    4444        } 
     
    5959     * Converts uploaded files to UploadedFile instances. 
    6060     * 
    61      * @param  array $file A (multi-dimensional) array of uploaded file information 
     61     * @param  array|UploadedFile $file A (multi-dimensional) array of uploaded file information 
    6262     * 
    6363     * @return array A (multi-dimensional) array of UploadedFile instances 
    6464     */ 
    65     protected function convertFileInformation(array $file) 
     65    protected function convertFileInformation($file) 
    6666    { 
     67        if ($file instanceof UploadedFile) { 
     68            return $file; 
     69        } 
    6770        $file = $this->fixPhpFilesArray($file); 
    6871        if (is_array($file)) { 
  • branches/2.0/src/Symfony/Component/HttpFoundation/Session.php

    r31885 r31898  
    170170 
    171171    /** 
     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    /** 
    172181     * Returns the session ID 
    173182     * 
  • branches/2.0/src/Symfony/Component/HttpKernel/Cache/EsiListener.php

    r31885 r31898  
    1919 * EsiListener adds a Surrogate-Control HTTP header when the Response needs to be parsed for ESI. 
    2020 * 
     21 * The filter method must be connected to the core.response event. 
     22 * 
    2123 * @author Fabien Potencier <fabien.potencier@symfony-project.com> 
    2224 */ 
     
    3739 
    3840    /** 
    39      * Registers a core.response listener to add the Surrogate-Control header to a Response when needed. 
    40      * 
    41      * @param EventDispatcher $dispatcher An EventDispatcher instance 
    42      * @param integer         $priority   The priority 
    43      */ 
    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     /** 
    5341     * Filters the Response. 
    5442     * 
     
    5846    public function filter($event, Response $response) 
    5947    { 
    60         if (HttpKernelInterface::MASTER_REQUEST !== $event->get('request_type')) { 
     48        if (HttpKernelInterface::MASTER_REQUEST !== $event->get('request_type') || null === $this->esi) { 
    6149            return $response; 
    6250        } 
  • branches/2.0/src/Symfony/Component/HttpKernel/ClassCollectionLoader.php

    r31885 r31898  
    4343        $classes = array_unique($classes); 
    4444 
    45         if ($adaptive) { 
    46             // don't include already declared classes 
    47             $classes = array_diff($classes, get_declared_classes(), get_declared_interfaces()); 
    48  
    49             // the cache is different depending on which classes are already declared 
    50             $name = $name.'-'.substr(md5(implode('|', $classes)), 0, 5); 
    51         } 
    52  
    5345        $cache = $cacheDir.'/'.$name.'.php'; 
    5446 
     
    5648        $reload = false; 
    5749        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 
    5855            $metadata = $cacheDir.'/'.$name.'.meta'; 
    5956            if (!file_exists($metadata) || !file_exists($cache)) { 
     
    8178 
    8279            return; 
     80        } 
     81 
     82        if ($adaptive) { 
     83            // don't include already declared classes 
     84            $classes = array_diff($classes, get_declared_classes(), get_declared_interfaces()); 
    8385        } 
    8486 
  • branches/2.0/src/Symfony/Component/HttpKernel/Debug/ExceptionListener.php

    r31885 r31898  
    2323 * ExceptionListener. 
    2424 * 
     25 * The handle method must be connected to the core.exception event. 
     26 * 
    2527 * @author Fabien Potencier <fabien.potencier@symfony-project.com> 
    2628 */ 
     
    3436        $this->controller = $controller; 
    3537        $this->logger = $logger; 
    36     } 
    37  
    38     /** 
    39      * Registers a core.exception listener. 
    40      * 
    41      * @param EventDispatcher $dispatcher An EventDispatcher instance 
    42      * @param integer         $priority   The priority 
    43      */ 
    44     public function register(EventDispatcher $dispatcher, $priority = 0) 
    45     { 
    46         $dispatcher->connect('core.exception', array($this, 'handle'), $priority); 
    4738    } 
    4839 
  • branches/2.0/src/Symfony/Component/HttpKernel/Kernel.php

    r31885 r31898  
    3030 
    3131/** 
    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. 
    3435 * 
    3536 * @author Fabien Potencier <fabien.potencier@symfony-project.org> 
     
    107108 
    108109    /** 
    109      * Checks whether the current kernel has been booted or not. 
    110      * 
    111      * @return Boolean $booted 
    112      */ 
    113     public function isBooted() 
    114     { 
    115         return $this->booted; 
    116     } 
    117  
    118     /** 
    119110     * Boots the current kernel. 
    120111     * 
     
    127118    { 
    128119        if (true === $this->booted) { 
    129             throw new \LogicException('The kernel is already booted.'); 
    130         } 
    131  
    132         require_once __DIR__.'/bootstrap.php'; 
     120            return; 
     121        } 
    133122 
    134123        // init bundles 
     
    399388        // init bundles 
    400389        $this->bundles = array(); 
     390        $this->bundleMap = array(); 
    401391        foreach ($this->registerBundles() as $bundle) { 
    402392            $name = $bundle->getName(); 
     
    436426        $reload = $this->debug ? $this->needsReload($class, $location) : false; 
    437427 
     428        $fresh = false; 
    438429        if ($reload || !file_exists($location.'.php')) { 
    439430            $container = $this->buildContainer(); 
    440431            $this->dumpContainer($container, $class, $location.'.php'); 
     432 
     433            $fresh = true; 
    441434        } 
    442435 
     
    445438        $this->container = new $class(); 
    446439        $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        } 
    447444    } 
    448445 
  • branches/2.0/src/Symfony/Component/HttpKernel/Profiler/ProfilerListener.php

    r31885 r31898  
    2121 * ProfilerListener collects data for the current request by listening to the core.response event. 
    2222 * 
     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 * 
    2326 * @author Fabien Potencier <fabien.potencier@symfony-project.com> 
    2427 */ 
     
    4245        $this->matcher = $matcher; 
    4346        $this->onlyException = $onlyException; 
    44     } 
    45  
    46     /** 
    47      * Registers a core.response and core.exception listeners. 
    48      * 
    49      * @param EventDispatcher $dispatcher An EventDispatcher instance 
    50      * @param integer         $priority   The priority 
    51      */ 
    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); 
    5647    } 
    5748 
  • branches/2.0/src/Symfony/Component/HttpKernel/Resources/bin/packager.php

    r31885 r31898  
    2424 
    2525ClassCollectionLoader::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', 
    2635    'Symfony\\Component\\HttpKernel\\Bundle\\Bundle', 
    27     'Symfony\\Component\\HttpKernel\\Bundle\\BundleInterface', 
    2836    'Symfony\\Component\\HttpKernel\\Debug\\ErrorHandler', 
    2937    'Symfony\\Component\\HttpKernel\\ClassCollectionLoader', 
    30     'Symfony\\Component\\HttpKernel\\Debug\\ExceptionListener', 
     38    'Symfony\\Component\\HttpKernel\\HttpKernelInterface', 
     39    'Symfony\\Component\\HttpKernel\\Kernel', 
    3140 
    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', 
    3747 
    3848), __DIR__.'/../..', 'bootstrap', false); 
  • branches/2.0/src/Symfony/Component/HttpKernel/ResponseListener.php

    r31885 r31898  
    1919 * ResponseListener fixes the Response Content-Type. 
    2020 * 
     21 * The filter method must be connected to the core.response event. 
     22 * 
    2123 * @author Fabien Potencier <fabien.potencier@symfony-project.com> 
    2224 */ 
    2325class ResponseListener 
    2426{ 
    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 instance 
    29      * @param integer         $priority   The priority 
    30      */ 
    31     public function register(EventDispatcher $dispatcher, $priority = 0) 
    32     { 
    33         $dispatcher->connect('core.response', array($this, 'filter'), $priority); 
    34     } 
    35  
    3627    /** 
    3728     * Filters the Response. 
  • branches/2.0/src/Symfony/Component/HttpKernel/Security/Firewall.php

    r31885 r31898  
    2525 * everything else for instance). 
    2626 * 
     27 * The handle method must be connected to the core.request event. 
     28 * 
    2729 * @author Fabien Potencier <fabien.potencier@symfony-project.com> 
    2830 */ 
     
    3840     * @param FirewallMap $map A FirewallMap instance 
    3941     */ 
    40     public function __construct(FirewallMapInterface $map
     42    public function __construct(FirewallMapInterface $map, EventDispatcher $dispatcher
    4143    { 
    4244        $this->map = $map; 
     45        $this->dispatcher = $dispatcher; 
    4346        $this->currentListeners = array(); 
    44     } 
    45  
    46     /** 
    47      * Registers a core.request listener to enforce security. 
    48      * 
    49      * @param EventDispatcher $dispatcher An EventDispatcher instance 
    50      * @param integer         $priority   The priority 
    51      */ 
    52     public function register(EventDispatcher $dispatcher, $priority = 0) 
    53     { 
    54         $dispatcher->connect('core.request', array($this, 'handle'), $priority); 
    55         $this->dispatcher = $dispatcher; 
    5647    } 
    5748 
  • branches/2.0/src/Symfony/Component/HttpKernel/bootstrap.php

    r31885 r31898  
    11<?php 
     2namespace Symfony\Component\DependencyInjection 
     3{ 
     4interface 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} 
     21namespace Symfony\Component\DependencyInjection 
     22{ 
     23use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; 
     24use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; 
     25use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag; 
     26class 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} 
     201namespace Symfony\Component\DependencyInjection 
     202{ 
     203interface ContainerAwareInterface 
     204{ 
     205    function setContainer(ContainerInterface $container = null); 
     206} 
     207} 
     208namespace Symfony\Component\DependencyInjection 
     209{ 
     210class ContainerAware implements ContainerAwareInterface 
     211{ 
     212    protected $container; 
     213    public function setContainer(ContainerInterface $container = null) 
     214    { 
     215        $this->container = $container; 
     216    } 
     217} 
     218} 
     219namespace Symfony\Component\DependencyInjection\ParameterBag 
     220{ 
     221interface 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} 
     231namespace Symfony\Component\DependencyInjection\ParameterBag 
     232{ 
     233class 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} 
     300namespace Symfony\Component\DependencyInjection\ParameterBag 
     301{ 
     302class 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} 
     322namespace Symfony\Component\HttpKernel\Bundle 
     323{ 
     324interface BundleInterface 
     325{ 
     326    function boot(); 
     327    function shutdown(); 
     328    function getParent(); 
     329    function getName(); 
     330    function getNamespace(); 
     331    function getPath(); 
     332} 
     333} 
    2334namespace Symfony\Component\HttpKernel\Bundle 
    3335{ 
     
    55387        } 
    56388    } 
    57 } 
    58 } 
    59 namespace Symfony\Component\HttpKernel\Bundle 
    60 { 
    61 interface BundleInterface 
    62 { 
    63     function boot(); 
    64     function shutdown(); 
    65     function getParent(); 
    66     function getName(); 
    67     function getNamespace(); 
    68     function getPath(); 
    69389} 
    70390} 
     
    115435        self::$loaded[$name] = true; 
    116436        $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         } 
    121437        $cache = $cacheDir.'/'.$name.'.php'; 
    122438                $reload = false; 
    123439        if ($autoReload) { 
     440            if ($adaptive) { 
     441                                $classes = array_diff($classes, get_declared_classes(), get_declared_interfaces()); 
     442            } 
    124443            $metadata = $cacheDir.'/'.$name.'.meta'; 
    125444            if (!file_exists($metadata) || !file_exists($cache)) { 
     
    143462            require_once $cache; 
    144463            return; 
     464        } 
     465        if ($adaptive) { 
     466                        $classes = array_diff($classes, get_declared_classes(), get_declared_interfaces()); 
    145467        } 
    146468        $files = array(); 
     
    215537} 
    216538} 
    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; 
     539namespace Symfony\Component\HttpKernel 
     540
     541use Symfony\Component\HttpFoundation\Request; 
     542interface 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
     549namespace Symfony\Component\HttpKernel 
     550
     551use Symfony\Component\DependencyInjection\ContainerInterface; 
     552use Symfony\Component\DependencyInjection\ContainerBuilder; 
     553use Symfony\Component\DependencyInjection\Dumper\PhpDumper; 
     554use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; 
     555use Symfony\Component\DependencyInjection\Loader\DelegatingLoader; 
     556use Symfony\Component\DependencyInjection\Loader\LoaderResolver; 
     557use Symfony\Component\DependencyInjection\Loader\LoaderInterface; 
     558use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; 
     559use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; 
     560use Symfony\Component\DependencyInjection\Loader\IniFileLoader; 
     561use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; 
     562use Symfony\Component\DependencyInjection\Loader\ClosureLoader; 
     563use Symfony\Component\HttpFoundation\Request; 
    223564use 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())); 
     565use Symfony\Component\HttpKernel\ClassCollectionLoader; 
     566use Symfony\Component\HttpKernel\Bundle\BundleInterface; 
     567abstract 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); 
    250590        } 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 
    259618        ); 
    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
     916namespace Symfony\Component\HttpFoundation 
     917
     918class 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
     975namespace Symfony\Component\HttpFoundation 
     976
     977use Symfony\Component\HttpFoundation\File\UploadedFile; 
     978class 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
     1049namespace Symfony\Component\HttpFoundation 
     1050
     1051class 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
     1065namespace Symfony\Component\HttpFoundation 
     1066
     1067class 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(); 
    2671103            } 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.'"'; 
    4361205                } 
    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
     1222namespace Symfony\Component\HttpFoundation 
     1223
     1224use Symfony\Component\HttpFoundation\SessionStorage\NativeSessionStorage; 
     1225use Symfony\Component\HttpFoundation\File\UploadedFile; 
     1226class 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
     1762namespace Symfony\Component\HttpFoundation 
     1763
     1764class 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  
    4040        $this->defaults = $defaults; 
    4141        $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; 
    4252    } 
    4353 
  • branches/2.0/src/Symfony/Component/Routing/Matcher/ApacheUrlMatcher.php

    r31885 r31898  
    3838 
    3939    /** 
     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    /** 
    4050     * Tries to match a URL based on Apache mod_rewrite matching. 
    4151     * 
  • branches/2.0/src/Symfony/Component/Routing/Matcher/UrlMatcher.php

    r31885 r31898  
    3838        $this->context = $context; 
    3939        $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; 
    4050    } 
    4151 
  • branches/2.0/src/Symfony/Component/Routing/Router.php

    r31885 r31898  
    9595    public function setContext(array $context = array()) 
    9696    { 
    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); 
    10899    } 
    109100 
  • branches/2.0/tests/Symfony/Tests/Component/DependencyInjection/Compiler/IntegrationTest.php

    r31885 r31898  
    3333 
    3434        $a = $container 
    35             ->register('a'
     35            ->register('a', '\stdClass'
    3636            ->addArgument(new Reference('c')) 
    3737        ; 
    3838 
    3939        $b = $container 
    40             ->register('b'
     40            ->register('b', '\stdClass'
    4141            ->addArgument(new Reference('c')) 
    4242            ->setPublic(false) 
     
    4444 
    4545        $c = $container 
    46             ->register('c'
     46            ->register('c', '\stdClass'
    4747            ->setPublic(false) 
    4848        ; 
     
    6262 
    6363        $a = $container 
    64             ->register('a'
     64            ->register('a', '\stdClass'
    6565            ->addArgument(new Reference('b')) 
    6666        ; 
     
    6969 
    7070        $c = $container 
    71             ->register('c'
     71            ->register('c', '\stdClass'
    7272            ->setPublic(false) 
    7373        ; 
     
    8787 
    8888        $container 
    89             ->register('a'
     89            ->register('a', '\stdClass'
    9090            ->addArgument(new Reference('b')) 
    9191            ->addMethodCall('setC', array(new Reference('c'))) 
     
    9393 
    9494        $container 
    95             ->register('b'
     95            ->register('b', '\stdClass'
    9696            ->addArgument(new Reference('c')) 
    9797            ->setPublic(false) 
     
    9999 
    100100        $container 
    101             ->register('c'
     101            ->register('c', '\stdClass'
    102102            ->setPublic(false) 
    103103        ; 
  • branches/2.0/tests/Symfony/Tests/Component/DependencyInjection/DefinitionTest.php

    r31885 r31898  
    127127 
    128128    /** 
     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    /** 
    129141     * @covers Symfony\Component\DependencyInjection\Definition::setConfigurator 
    130142     * @covers Symfony\Component\DependencyInjection\Definition::getConfigurator 
     
    153165     * @covers Symfony\Component\DependencyInjection\Definition::getTag 
    154166     * @covers Symfony\Component\DependencyInjection\Definition::getTags 
     167     * @covers Symfony\Component\DependencyInjection\Definition::hasTag 
    155168     */ 
    156169    public function testTags() 
     
    158171        $def = new Definition('stdClass'); 
    159172        $this->assertEquals(array(), $def->getTag('foo'), '->getTag() returns an empty array if the tag is not defined'); 
     173        $this->assertFalse($def->hasTag('foo')); 
    160174        $this->assertSame($def, $def->addTag('foo'), '->addTag() implements a fluent interface'); 
     175        $this->assertTrue($def->hasTag('foo')); 
    161176        $this->assertEquals(array(array()), $def->getTag('foo'), '->getTag() returns attributes for a tag name'); 
    162177        $def->addTag('foo', array('foo' => 'bar')); 
  • branches/2.0/tests/Symfony/Tests/Component/HttpFoundation/FileBagTest.php

    r31885 r31898  
    111111    } 
    112112 
     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 
    113123    protected function createTempFile() 
    114124    { 
  • branches/2.0/tests/Symfony/Tests/Component/HttpKernel/Cache/EsiListenerTest.php

    r31885 r31898  
    2525        $dispatcher = new EventDispatcher(); 
    2626        $listener = new EsiListener(new Esi()); 
    27         $listener->register($dispatcher); 
     27        $dispatcher->connect('core.response', array($listener, 'filter')); 
    2828 
    2929        $event = new Event(null, 'core.response', array('request_type' => HttpKernelInterface::SUB_REQUEST)); 
     
    3333    } 
    3434 
    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  
    4435    public function testFilterWhenThereIsSomeEsiIncludes() 
    4536    { 
    4637        $dispatcher = new EventDispatcher(); 
    4738        $listener = new EsiListener(new Esi()); 
    48         $listener->register($dispatcher); 
     39        $dispatcher->connect('core.response', array($listener, 'filter')); 
    4940 
    5041        $event = new Event(null, 'core.response', array('request_type' => HttpKernelInterface::MASTER_REQUEST)); 
     
    5849        $dispatcher = new EventDispatcher(); 
    5950        $listener = new EsiListener(new Esi()); 
    60         $listener->register($dispatcher); 
     51        $dispatcher->connect('core.response', array($listener, 'filter')); 
    6152 
    6253        $event = new Event(null, 'core.response', array('request_type' => HttpKernelInterface::MASTER_REQUEST)); 
  • branches/2.0/tests/Symfony/Tests/Component/HttpKernel/ResponseListenerTest.php

    r31403 r31898  
    6161        $dispatcher = new EventDispatcher(); 
    6262        $listener = new ResponseListener(); 
    63         $listener->register($dispatcher); 
     63        $dispatcher->connect('core.response', array($listener, 'filter')); 
    6464 
    6565        return $dispatcher;