merged 2.0
This commit is contained in:
commit
adf07f1e53
@ -37,6 +37,10 @@ class AddCacheWarmerPass implements CompilerPassInterface
|
|||||||
$warmers[$priority][] = new Reference($id);
|
$warmers[$priority][] = new Reference($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (empty($warmers)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// sort by priority and flatten
|
// sort by priority and flatten
|
||||||
krsort($warmers);
|
krsort($warmers);
|
||||||
$warmers = call_user_func_array('array_merge', $warmers);
|
$warmers = call_user_func_array('array_merge', $warmers);
|
||||||
|
@ -0,0 +1,92 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler;
|
||||||
|
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
use Symfony\Component\DependencyInjection\Definition;
|
||||||
|
use Symfony\Component\DependencyInjection\Reference;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddCacheWarmerPass;
|
||||||
|
|
||||||
|
class AddCacheWarmerPassTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
public function testThatCacheWarmersAreProcessedInPriorityOrder()
|
||||||
|
{
|
||||||
|
$services = array(
|
||||||
|
'my_cache_warmer_service1' => array(0 => array('priority' => 100)),
|
||||||
|
'my_cache_warmer_service2' => array(0 => array('priority' => 200)),
|
||||||
|
'my_cache_warmer_service3' => array()
|
||||||
|
);
|
||||||
|
|
||||||
|
$definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
|
||||||
|
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder');
|
||||||
|
|
||||||
|
$container->expects($this->atLeastOnce())
|
||||||
|
->method('findTaggedServiceIds')
|
||||||
|
->will($this->returnValue($services));
|
||||||
|
$container->expects($this->atLeastOnce())
|
||||||
|
->method('getDefinition')
|
||||||
|
->with('cache_warmer')
|
||||||
|
->will($this->returnValue($definition));
|
||||||
|
$container->expects($this->atLeastOnce())
|
||||||
|
->method('hasDefinition')
|
||||||
|
->with('cache_warmer')
|
||||||
|
->will($this->returnValue(true));
|
||||||
|
|
||||||
|
$definition->expects($this->once())
|
||||||
|
->method('replaceArgument')
|
||||||
|
->with(0, array(
|
||||||
|
new Reference('my_cache_warmer_service2'),
|
||||||
|
new Reference('my_cache_warmer_service1'),
|
||||||
|
new Reference('my_cache_warmer_service3')
|
||||||
|
));
|
||||||
|
|
||||||
|
$addCacheWarmerPass = new AddCacheWarmerPass();
|
||||||
|
$addCacheWarmerPass->process($container);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testThatCompilerPassIsIgnoredIfThereIsNoCacheWarmerDefinition()
|
||||||
|
{
|
||||||
|
$definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
|
||||||
|
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder');
|
||||||
|
|
||||||
|
$container->expects($this->never())->method('findTaggedServiceIds');
|
||||||
|
$container->expects($this->never())->method('getDefinition');
|
||||||
|
$container->expects($this->atLeastOnce())
|
||||||
|
->method('hasDefinition')
|
||||||
|
->with('cache_warmer')
|
||||||
|
->will($this->returnValue(false));
|
||||||
|
$definition->expects($this->never())->method('replaceArgument');
|
||||||
|
|
||||||
|
$addCacheWarmerPass = new AddCacheWarmerPass();
|
||||||
|
$addCacheWarmerPass->process($container);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testThatCacheWarmersMightBeNotDefined()
|
||||||
|
{
|
||||||
|
$definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
|
||||||
|
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder');
|
||||||
|
|
||||||
|
$container->expects($this->atLeastOnce())
|
||||||
|
->method('findTaggedServiceIds')
|
||||||
|
->will($this->returnValue(array()));
|
||||||
|
$container->expects($this->never())->method('getDefinition');
|
||||||
|
$container->expects($this->atLeastOnce())
|
||||||
|
->method('hasDefinition')
|
||||||
|
->with('cache_warmer')
|
||||||
|
->will($this->returnValue(true));
|
||||||
|
|
||||||
|
$definition->expects($this->never())->method('replaceArgument');
|
||||||
|
|
||||||
|
$addCacheWarmerPass = new AddCacheWarmerPass();
|
||||||
|
$addCacheWarmerPass->process($container);
|
||||||
|
}
|
||||||
|
}
|
@ -49,7 +49,7 @@ class ExceptionController extends ContainerAware
|
|||||||
$this->findTemplate($templating, $format, $code, $this->container->get('kernel')->isDebug()),
|
$this->findTemplate($templating, $format, $code, $this->container->get('kernel')->isDebug()),
|
||||||
array(
|
array(
|
||||||
'status_code' => $code,
|
'status_code' => $code,
|
||||||
'status_text' => Response::$statusTexts[$code],
|
'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '',
|
||||||
'exception' => $exception,
|
'exception' => $exception,
|
||||||
'logger' => $logger,
|
'logger' => $logger,
|
||||||
'currentContent' => $currentContent,
|
'currentContent' => $currentContent,
|
||||||
|
@ -58,7 +58,7 @@ class TwigExtension extends Extension
|
|||||||
$container->setParameter('twig.form.resources', $config['form']['resources']);
|
$container->setParameter('twig.form.resources', $config['form']['resources']);
|
||||||
|
|
||||||
$reflClass = new \ReflectionClass('Symfony\Bridge\Twig\Extension\FormExtension');
|
$reflClass = new \ReflectionClass('Symfony\Bridge\Twig\Extension\FormExtension');
|
||||||
$container->getDefinition('twig.loader')->addMethodCall('addPath', array(dirname(dirname($reflClass->getFileName())) . '/Resources/views/Form'));
|
$container->getDefinition('twig.loader')->addMethodCall('addPath', array(dirname(dirname($reflClass->getFileName())).'/Resources/views/Form'));
|
||||||
|
|
||||||
if (!empty($config['globals'])) {
|
if (!empty($config['globals'])) {
|
||||||
$def = $container->getDefinition('twig');
|
$def = $container->getDefinition('twig');
|
||||||
|
@ -170,6 +170,12 @@ class ValidatorTypeGuesser implements FormTypeGuesserInterface
|
|||||||
case 'Symfony\Component\Validator\Constraints\Range':
|
case 'Symfony\Component\Validator\Constraints\Range':
|
||||||
case 'Symfony\Component\Validator\Constraints\Max':
|
case 'Symfony\Component\Validator\Constraints\Max':
|
||||||
return new TypeGuess('number', array(), Guess::LOW_CONFIDENCE);
|
return new TypeGuess('number', array(), Guess::LOW_CONFIDENCE);
|
||||||
|
|
||||||
|
case 'Symfony\Component\Validator\Constraints\Time':
|
||||||
|
return new TypeGuess('time', array('input'=>'string'), Guess::HIGH_CONFIDENCE);
|
||||||
|
|
||||||
|
case 'Symfony\Component\Validator\Constraints\Url':
|
||||||
|
return new TypeGuess('url', array(), Guess::HIGH_CONFIDENCE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -392,7 +392,7 @@ abstract class Kernel implements KernelInterface, TerminableInterface
|
|||||||
{
|
{
|
||||||
if (null === $this->rootDir) {
|
if (null === $this->rootDir) {
|
||||||
$r = new \ReflectionObject($this);
|
$r = new \ReflectionObject($this);
|
||||||
$this->rootDir = dirname($r->getFileName());
|
$this->rootDir = str_replace('\\', '/', dirname($r->getFileName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->rootDir;
|
return $this->rootDir;
|
||||||
|
@ -39,6 +39,8 @@ interface LoaderInterface
|
|||||||
* @param TemplateReferenceInterface $template A template
|
* @param TemplateReferenceInterface $template A template
|
||||||
* @param integer $time The last modification time of the cached template (timestamp)
|
* @param integer $time The last modification time of the cached template (timestamp)
|
||||||
*
|
*
|
||||||
|
* @return Boolean
|
||||||
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
function isFresh(TemplateReferenceInterface $template, $time);
|
function isFresh(TemplateReferenceInterface $template, $time);
|
||||||
|
Reference in New Issue
Block a user