Skip to content

Commit adf07f1

Browse files
committed
merged 2.0
2 parents 9e95199 + 167779e commit adf07f1

File tree

7 files changed

+107
-3
lines changed

7 files changed

+107
-3
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddCacheWarmerPass.php

+4
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ public function process(ContainerBuilder $container)
3737
$warmers[$priority][] = new Reference($id);
3838
}
3939

40+
if (empty($warmers)) {
41+
return;
42+
}
43+
4044
// sort by priority and flatten
4145
krsort($warmers);
4246
$warmers = call_user_func_array('array_merge', $warmers);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler;
13+
14+
use Symfony\Component\DependencyInjection\ContainerBuilder;
15+
use Symfony\Component\DependencyInjection\Definition;
16+
use Symfony\Component\DependencyInjection\Reference;
17+
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddCacheWarmerPass;
18+
19+
class AddCacheWarmerPassTest extends \PHPUnit_Framework_TestCase
20+
{
21+
public function testThatCacheWarmersAreProcessedInPriorityOrder()
22+
{
23+
$services = array(
24+
'my_cache_warmer_service1' => array(0 => array('priority' => 100)),
25+
'my_cache_warmer_service2' => array(0 => array('priority' => 200)),
26+
'my_cache_warmer_service3' => array()
27+
);
28+
29+
$definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
30+
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder');
31+
32+
$container->expects($this->atLeastOnce())
33+
->method('findTaggedServiceIds')
34+
->will($this->returnValue($services));
35+
$container->expects($this->atLeastOnce())
36+
->method('getDefinition')
37+
->with('cache_warmer')
38+
->will($this->returnValue($definition));
39+
$container->expects($this->atLeastOnce())
40+
->method('hasDefinition')
41+
->with('cache_warmer')
42+
->will($this->returnValue(true));
43+
44+
$definition->expects($this->once())
45+
->method('replaceArgument')
46+
->with(0, array(
47+
new Reference('my_cache_warmer_service2'),
48+
new Reference('my_cache_warmer_service1'),
49+
new Reference('my_cache_warmer_service3')
50+
));
51+
52+
$addCacheWarmerPass = new AddCacheWarmerPass();
53+
$addCacheWarmerPass->process($container);
54+
}
55+
56+
public function testThatCompilerPassIsIgnoredIfThereIsNoCacheWarmerDefinition()
57+
{
58+
$definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
59+
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder');
60+
61+
$container->expects($this->never())->method('findTaggedServiceIds');
62+
$container->expects($this->never())->method('getDefinition');
63+
$container->expects($this->atLeastOnce())
64+
->method('hasDefinition')
65+
->with('cache_warmer')
66+
->will($this->returnValue(false));
67+
$definition->expects($this->never())->method('replaceArgument');
68+
69+
$addCacheWarmerPass = new AddCacheWarmerPass();
70+
$addCacheWarmerPass->process($container);
71+
}
72+
73+
public function testThatCacheWarmersMightBeNotDefined()
74+
{
75+
$definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
76+
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder');
77+
78+
$container->expects($this->atLeastOnce())
79+
->method('findTaggedServiceIds')
80+
->will($this->returnValue(array()));
81+
$container->expects($this->never())->method('getDefinition');
82+
$container->expects($this->atLeastOnce())
83+
->method('hasDefinition')
84+
->with('cache_warmer')
85+
->will($this->returnValue(true));
86+
87+
$definition->expects($this->never())->method('replaceArgument');
88+
89+
$addCacheWarmerPass = new AddCacheWarmerPass();
90+
$addCacheWarmerPass->process($container);
91+
}
92+
}

src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function showAction(FlattenException $exception, DebugLoggerInterface $lo
4949
$this->findTemplate($templating, $format, $code, $this->container->get('kernel')->isDebug()),
5050
array(
5151
'status_code' => $code,
52-
'status_text' => Response::$statusTexts[$code],
52+
'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '',
5353
'exception' => $exception,
5454
'logger' => $logger,
5555
'currentContent' => $currentContent,

src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function load(array $configs, ContainerBuilder $container)
5858
$container->setParameter('twig.form.resources', $config['form']['resources']);
5959

6060
$reflClass = new \ReflectionClass('Symfony\Bridge\Twig\Extension\FormExtension');
61-
$container->getDefinition('twig.loader')->addMethodCall('addPath', array(dirname(dirname($reflClass->getFileName())) . '/Resources/views/Form'));
61+
$container->getDefinition('twig.loader')->addMethodCall('addPath', array(dirname(dirname($reflClass->getFileName())).'/Resources/views/Form'));
6262

6363
if (!empty($config['globals'])) {
6464
$def = $container->getDefinition('twig');

src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php

+6
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,12 @@ public function guessTypeForConstraint(Constraint $constraint)
170170
case 'Symfony\Component\Validator\Constraints\Range':
171171
case 'Symfony\Component\Validator\Constraints\Max':
172172
return new TypeGuess('number', array(), Guess::LOW_CONFIDENCE);
173+
174+
case 'Symfony\Component\Validator\Constraints\Time':
175+
return new TypeGuess('time', array('input'=>'string'), Guess::HIGH_CONFIDENCE);
176+
177+
case 'Symfony\Component\Validator\Constraints\Url':
178+
return new TypeGuess('url', array(), Guess::HIGH_CONFIDENCE);
173179
}
174180
}
175181

src/Symfony/Component/HttpKernel/Kernel.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ public function getRootDir()
392392
{
393393
if (null === $this->rootDir) {
394394
$r = new \ReflectionObject($this);
395-
$this->rootDir = dirname($r->getFileName());
395+
$this->rootDir = str_replace('\\', '/', dirname($r->getFileName()));
396396
}
397397

398398
return $this->rootDir;

src/Symfony/Component/Templating/Loader/LoaderInterface.php

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ function load(TemplateReferenceInterface $template);
3939
* @param TemplateReferenceInterface $template A template
4040
* @param integer $time The last modification time of the cached template (timestamp)
4141
*
42+
* @return Boolean
43+
*
4244
* @api
4345
*/
4446
function isFresh(TemplateReferenceInterface $template, $time);

0 commit comments

Comments
 (0)