Removed support for PHP templating everywhere
This commit is contained in:
parent
5e293d9e58
commit
d5be373cac
@ -1,6 +1,11 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
5.0.0
|
||||
-----
|
||||
|
||||
* removed `TwigEngine` class, use `\Twig\Environment` instead.
|
||||
|
||||
4.4.0
|
||||
-----
|
||||
|
||||
|
@ -1,25 +0,0 @@
|
||||
<?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\Bridge\Twig\Tests\Extension\Fixtures;
|
||||
|
||||
use Twig\Loader\FilesystemLoader;
|
||||
|
||||
class StubFilesystemLoader extends FilesystemLoader
|
||||
{
|
||||
protected function findTemplate($name, $throw = true)
|
||||
{
|
||||
// strip away bundle name
|
||||
$parts = explode(':', $name);
|
||||
|
||||
return parent::findTemplate(end($parts), $throw);
|
||||
}
|
||||
}
|
@ -14,11 +14,11 @@ namespace Symfony\Bridge\Twig\Tests\Extension;
|
||||
use Symfony\Bridge\Twig\Extension\FormExtension;
|
||||
use Symfony\Bridge\Twig\Extension\TranslationExtension;
|
||||
use Symfony\Bridge\Twig\Form\TwigRendererEngine;
|
||||
use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubFilesystemLoader;
|
||||
use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubTranslator;
|
||||
use Symfony\Component\Form\FormRenderer;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Twig\Environment;
|
||||
use Twig\Loader\FilesystemLoader;
|
||||
|
||||
class FormExtensionBootstrap3HorizontalLayoutTest extends AbstractBootstrap3HorizontalLayoutTest
|
||||
{
|
||||
@ -37,7 +37,7 @@ class FormExtensionBootstrap3HorizontalLayoutTest extends AbstractBootstrap3Hori
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$loader = new StubFilesystemLoader([
|
||||
$loader = new FilesystemLoader([
|
||||
__DIR__.'/../../Resources/views/Form',
|
||||
__DIR__.'/Fixtures/templates/form',
|
||||
]);
|
||||
|
@ -14,11 +14,11 @@ namespace Symfony\Bridge\Twig\Tests\Extension;
|
||||
use Symfony\Bridge\Twig\Extension\FormExtension;
|
||||
use Symfony\Bridge\Twig\Extension\TranslationExtension;
|
||||
use Symfony\Bridge\Twig\Form\TwigRendererEngine;
|
||||
use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubFilesystemLoader;
|
||||
use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubTranslator;
|
||||
use Symfony\Component\Form\FormRenderer;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Twig\Environment;
|
||||
use Twig\Loader\FilesystemLoader;
|
||||
|
||||
class FormExtensionBootstrap3LayoutTest extends AbstractBootstrap3LayoutTest
|
||||
{
|
||||
@ -33,7 +33,7 @@ class FormExtensionBootstrap3LayoutTest extends AbstractBootstrap3LayoutTest
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$loader = new StubFilesystemLoader([
|
||||
$loader = new FilesystemLoader([
|
||||
__DIR__.'/../../Resources/views/Form',
|
||||
__DIR__.'/Fixtures/templates/form',
|
||||
]);
|
||||
@ -76,7 +76,7 @@ class FormExtensionBootstrap3LayoutTest extends AbstractBootstrap3LayoutTest
|
||||
|
||||
public function testMoneyWidgetInIso()
|
||||
{
|
||||
$environment = new Environment(new StubFilesystemLoader([
|
||||
$environment = new Environment(new FilesystemLoader([
|
||||
__DIR__.'/../../Resources/views/Form',
|
||||
__DIR__.'/Fixtures/templates/form',
|
||||
]), ['strict_variables' => true]);
|
||||
|
@ -14,11 +14,11 @@ namespace Symfony\Bridge\Twig\Tests\Extension;
|
||||
use Symfony\Bridge\Twig\Extension\FormExtension;
|
||||
use Symfony\Bridge\Twig\Extension\TranslationExtension;
|
||||
use Symfony\Bridge\Twig\Form\TwigRendererEngine;
|
||||
use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubFilesystemLoader;
|
||||
use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubTranslator;
|
||||
use Symfony\Component\Form\FormRenderer;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Twig\Environment;
|
||||
use Twig\Loader\FilesystemLoader;
|
||||
|
||||
/**
|
||||
* Class providing test cases for the Bootstrap 4 Twig form theme.
|
||||
@ -39,7 +39,7 @@ class FormExtensionBootstrap4HorizontalLayoutTest extends AbstractBootstrap4Hori
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$loader = new StubFilesystemLoader([
|
||||
$loader = new FilesystemLoader([
|
||||
__DIR__.'/../../Resources/views/Form',
|
||||
__DIR__.'/Fixtures/templates/form',
|
||||
]);
|
||||
|
@ -14,11 +14,11 @@ namespace Symfony\Bridge\Twig\Tests\Extension;
|
||||
use Symfony\Bridge\Twig\Extension\FormExtension;
|
||||
use Symfony\Bridge\Twig\Extension\TranslationExtension;
|
||||
use Symfony\Bridge\Twig\Form\TwigRendererEngine;
|
||||
use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubFilesystemLoader;
|
||||
use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubTranslator;
|
||||
use Symfony\Component\Form\FormRenderer;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Twig\Environment;
|
||||
use Twig\Loader\FilesystemLoader;
|
||||
|
||||
/**
|
||||
* Class providing test cases for the Bootstrap 4 horizontal Twig form theme.
|
||||
@ -37,7 +37,7 @@ class FormExtensionBootstrap4LayoutTest extends AbstractBootstrap4LayoutTest
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$loader = new StubFilesystemLoader([
|
||||
$loader = new FilesystemLoader([
|
||||
__DIR__.'/../../Resources/views/Form',
|
||||
__DIR__.'/Fixtures/templates/form',
|
||||
]);
|
||||
@ -80,7 +80,7 @@ class FormExtensionBootstrap4LayoutTest extends AbstractBootstrap4LayoutTest
|
||||
|
||||
public function testMoneyWidgetInIso()
|
||||
{
|
||||
$environment = new Environment(new StubFilesystemLoader([
|
||||
$environment = new Environment(new FilesystemLoader([
|
||||
__DIR__.'/../../Resources/views/Form',
|
||||
__DIR__.'/Fixtures/templates/form',
|
||||
]), ['strict_variables' => true]);
|
||||
|
@ -14,13 +14,13 @@ namespace Symfony\Bridge\Twig\Tests\Extension;
|
||||
use Symfony\Bridge\Twig\Extension\FormExtension;
|
||||
use Symfony\Bridge\Twig\Extension\TranslationExtension;
|
||||
use Symfony\Bridge\Twig\Form\TwigRendererEngine;
|
||||
use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubFilesystemLoader;
|
||||
use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubTranslator;
|
||||
use Symfony\Component\Form\ChoiceList\View\ChoiceView;
|
||||
use Symfony\Component\Form\FormRenderer;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\Form\Tests\AbstractDivLayoutTest;
|
||||
use Twig\Environment;
|
||||
use Twig\Loader\FilesystemLoader;
|
||||
|
||||
class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
|
||||
{
|
||||
@ -37,7 +37,7 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$loader = new StubFilesystemLoader([
|
||||
$loader = new FilesystemLoader([
|
||||
__DIR__.'/../../Resources/views/Form',
|
||||
__DIR__.'/Fixtures/templates/form',
|
||||
]);
|
||||
@ -169,7 +169,7 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
|
||||
|
||||
public function testMoneyWidgetInIso()
|
||||
{
|
||||
$environment = new Environment(new StubFilesystemLoader([
|
||||
$environment = new Environment(new FilesystemLoader([
|
||||
__DIR__.'/../../Resources/views/Form',
|
||||
__DIR__.'/Fixtures/templates/form',
|
||||
]), ['strict_variables' => true]);
|
||||
|
@ -14,12 +14,12 @@ namespace Symfony\Bridge\Twig\Tests\Extension;
|
||||
use Symfony\Bridge\Twig\Extension\FormExtension;
|
||||
use Symfony\Bridge\Twig\Extension\TranslationExtension;
|
||||
use Symfony\Bridge\Twig\Form\TwigRendererEngine;
|
||||
use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubFilesystemLoader;
|
||||
use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubTranslator;
|
||||
use Symfony\Component\Form\FormRenderer;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\Form\Tests\AbstractTableLayoutTest;
|
||||
use Twig\Environment;
|
||||
use Twig\Loader\FilesystemLoader;
|
||||
|
||||
class FormExtensionTableLayoutTest extends AbstractTableLayoutTest
|
||||
{
|
||||
@ -36,7 +36,7 @@ class FormExtensionTableLayoutTest extends AbstractTableLayoutTest
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$loader = new StubFilesystemLoader([
|
||||
$loader = new FilesystemLoader([
|
||||
__DIR__.'/../../Resources/views/Form',
|
||||
__DIR__.'/Fixtures/templates/form',
|
||||
]);
|
||||
|
@ -1,84 +0,0 @@
|
||||
<?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\Bridge\Twig\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\Twig\TwigEngine;
|
||||
use Symfony\Component\Templating\TemplateReference;
|
||||
use Twig\Environment;
|
||||
use Twig\Loader\ArrayLoader;
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
class TwigEngineTest extends TestCase
|
||||
{
|
||||
public function testExistsWithTemplateInstances()
|
||||
{
|
||||
$engine = $this->getTwig();
|
||||
|
||||
$this->assertTrue($engine->exists($this->getMockForAbstractClass('Twig\Template', [], '', false)));
|
||||
}
|
||||
|
||||
public function testExistsWithNonExistentTemplates()
|
||||
{
|
||||
$engine = $this->getTwig();
|
||||
|
||||
$this->assertFalse($engine->exists('foobar'));
|
||||
$this->assertFalse($engine->exists(new TemplateReference('foorbar')));
|
||||
}
|
||||
|
||||
public function testExistsWithTemplateWithSyntaxErrors()
|
||||
{
|
||||
$engine = $this->getTwig();
|
||||
|
||||
$this->assertTrue($engine->exists('error'));
|
||||
$this->assertTrue($engine->exists(new TemplateReference('error')));
|
||||
}
|
||||
|
||||
public function testExists()
|
||||
{
|
||||
$engine = $this->getTwig();
|
||||
|
||||
$this->assertTrue($engine->exists('index'));
|
||||
$this->assertTrue($engine->exists(new TemplateReference('index')));
|
||||
}
|
||||
|
||||
public function testRender()
|
||||
{
|
||||
$engine = $this->getTwig();
|
||||
|
||||
$this->assertSame('foo', $engine->render('index'));
|
||||
$this->assertSame('foo', $engine->render(new TemplateReference('index')));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Twig\Error\SyntaxError
|
||||
*/
|
||||
public function testRenderWithError()
|
||||
{
|
||||
$engine = $this->getTwig();
|
||||
|
||||
$engine->render(new TemplateReference('error'));
|
||||
}
|
||||
|
||||
protected function getTwig()
|
||||
{
|
||||
$twig = new Environment(new ArrayLoader([
|
||||
'index' => 'foo',
|
||||
'error' => '{{ foo }',
|
||||
]));
|
||||
$parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock();
|
||||
|
||||
return new TwigEngine($twig, $parser);
|
||||
}
|
||||
}
|
@ -1,134 +0,0 @@
|
||||
<?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\Bridge\Twig;
|
||||
|
||||
@trigger_error('The '.TwigEngine::class.' class is deprecated since version 4.3 and will be removed in 5.0; use \Twig\Environment instead.', E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\Templating\EngineInterface;
|
||||
use Symfony\Component\Templating\StreamingEngineInterface;
|
||||
use Symfony\Component\Templating\TemplateNameParserInterface;
|
||||
use Symfony\Component\Templating\TemplateReferenceInterface;
|
||||
use Twig\Environment;
|
||||
use Twig\Error\Error;
|
||||
use Twig\Error\LoaderError;
|
||||
use Twig\Loader\ExistsLoaderInterface;
|
||||
use Twig\Template;
|
||||
|
||||
/**
|
||||
* This engine knows how to render Twig templates.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
|
||||
*/
|
||||
class TwigEngine implements EngineInterface, StreamingEngineInterface
|
||||
{
|
||||
protected $environment;
|
||||
protected $parser;
|
||||
|
||||
public function __construct(Environment $environment, TemplateNameParserInterface $parser)
|
||||
{
|
||||
$this->environment = $environment;
|
||||
$this->parser = $parser;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* It also supports Template as name parameter.
|
||||
*
|
||||
* @throws Error if something went wrong like a thrown exception while rendering the template
|
||||
*/
|
||||
public function render($name, array $parameters = [])
|
||||
{
|
||||
return $this->load($name)->render($parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* It also supports Template as name parameter.
|
||||
*
|
||||
* @throws Error if something went wrong like a thrown exception while rendering the template
|
||||
*/
|
||||
public function stream($name, array $parameters = [])
|
||||
{
|
||||
$this->load($name)->display($parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* It also supports Template as name parameter.
|
||||
*/
|
||||
public function exists($name)
|
||||
{
|
||||
if ($name instanceof Template) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$loader = $this->environment->getLoader();
|
||||
|
||||
if ($loader instanceof ExistsLoaderInterface || method_exists($loader, 'exists')) {
|
||||
return $loader->exists((string) $name);
|
||||
}
|
||||
|
||||
try {
|
||||
// cast possible TemplateReferenceInterface to string because the
|
||||
// EngineInterface supports them but LoaderInterface does not
|
||||
$loader->getSourceContext((string) $name)->getCode();
|
||||
} catch (LoaderError $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* It also supports Template as name parameter.
|
||||
*/
|
||||
public function supports($name)
|
||||
{
|
||||
if ($name instanceof Template) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$template = $this->parser->parse($name);
|
||||
|
||||
return 'twig' === $template->get('engine');
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the given template.
|
||||
*
|
||||
* @param string|TemplateReferenceInterface|Template $name A template name or an instance of
|
||||
* TemplateReferenceInterface or Template
|
||||
*
|
||||
* @return Template
|
||||
*
|
||||
* @throws \InvalidArgumentException if the template does not exist
|
||||
*/
|
||||
protected function load($name)
|
||||
{
|
||||
if ($name instanceof Template) {
|
||||
return $name;
|
||||
}
|
||||
|
||||
try {
|
||||
return $this->environment->loadTemplate((string) $name);
|
||||
} catch (LoaderError $e) {
|
||||
throw new \InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
}
|
||||
}
|
@ -30,7 +30,6 @@
|
||||
"symfony/mime": "^4.4|^5.0",
|
||||
"symfony/polyfill-intl-icu": "~1.0",
|
||||
"symfony/routing": "^4.4|^5.0",
|
||||
"symfony/templating": "^4.4|^5.0",
|
||||
"symfony/translation": "^4.4|^5.0",
|
||||
"symfony/yaml": "^4.4|^5.0",
|
||||
"symfony/security-acl": "^2.8|^3.0",
|
||||
@ -56,7 +55,6 @@
|
||||
"symfony/form": "For using the FormExtension",
|
||||
"symfony/http-kernel": "For using the HttpKernelExtension",
|
||||
"symfony/routing": "For using the RoutingExtension",
|
||||
"symfony/templating": "For using the TwigEngine",
|
||||
"symfony/translation": "For using the TranslationExtension",
|
||||
"symfony/yaml": "For using the YamlExtension",
|
||||
"symfony/security-core": "For using the SecurityExtension",
|
||||
|
@ -5,6 +5,7 @@ CHANGELOG
|
||||
-----
|
||||
|
||||
* Removed support to load translation resources from the legacy directories `src/Resources/translations/` and `src/Resources/<BundleName>/translations/`
|
||||
* Removed support for PHP templating, use Twig instead
|
||||
|
||||
4.4.0
|
||||
-----
|
||||
|
@ -1,115 +0,0 @@
|
||||
<?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\CacheWarmer;
|
||||
|
||||
@trigger_error('The '.TemplateFinder::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\Finder\Finder;
|
||||
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
use Symfony\Component\Templating\TemplateNameParserInterface;
|
||||
use Symfony\Component\Templating\TemplateReferenceInterface;
|
||||
|
||||
/**
|
||||
* Finds all the templates.
|
||||
*
|
||||
* @author Victor Berchet <victor@suumit.com>
|
||||
*
|
||||
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
|
||||
*/
|
||||
class TemplateFinder implements TemplateFinderInterface
|
||||
{
|
||||
private $kernel;
|
||||
private $parser;
|
||||
private $rootDir;
|
||||
private $templates;
|
||||
|
||||
/**
|
||||
* @param KernelInterface $kernel A KernelInterface instance
|
||||
* @param TemplateNameParserInterface $parser A TemplateNameParserInterface instance
|
||||
* @param string $rootDir The directory where global templates can be stored
|
||||
*/
|
||||
public function __construct(KernelInterface $kernel, TemplateNameParserInterface $parser, string $rootDir)
|
||||
{
|
||||
$this->kernel = $kernel;
|
||||
$this->parser = $parser;
|
||||
$this->rootDir = $rootDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find all the templates in the bundle and in the kernel Resources folder.
|
||||
*
|
||||
* @return TemplateReferenceInterface[]
|
||||
*/
|
||||
public function findAllTemplates()
|
||||
{
|
||||
if (null !== $this->templates) {
|
||||
return $this->templates;
|
||||
}
|
||||
|
||||
$templates = [];
|
||||
|
||||
foreach ($this->kernel->getBundles() as $bundle) {
|
||||
$templates = array_merge($templates, $this->findTemplatesInBundle($bundle));
|
||||
}
|
||||
|
||||
$templates = array_merge($templates, $this->findTemplatesInFolder($this->rootDir.'/views'));
|
||||
|
||||
return $this->templates = $templates;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find templates in the given directory.
|
||||
*
|
||||
* @param string $dir The folder where to look for templates
|
||||
*
|
||||
* @return TemplateReferenceInterface[]
|
||||
*/
|
||||
private function findTemplatesInFolder($dir)
|
||||
{
|
||||
$templates = [];
|
||||
|
||||
if (is_dir($dir)) {
|
||||
$finder = new Finder();
|
||||
foreach ($finder->files()->followLinks()->in($dir) as $file) {
|
||||
$template = $this->parser->parse($file->getRelativePathname());
|
||||
if (false !== $template) {
|
||||
$templates[] = $template;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $templates;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find templates in the given bundle.
|
||||
*
|
||||
* @param BundleInterface $bundle The bundle where to look for templates
|
||||
*
|
||||
* @return TemplateReferenceInterface[]
|
||||
*/
|
||||
private function findTemplatesInBundle(BundleInterface $bundle)
|
||||
{
|
||||
$name = $bundle->getName();
|
||||
$templates = array_unique(array_merge(
|
||||
$this->findTemplatesInFolder($bundle->getPath().'/Resources/views'),
|
||||
$this->findTemplatesInFolder($this->rootDir.'/'.$name.'/views')
|
||||
));
|
||||
|
||||
foreach ($templates as $i => $template) {
|
||||
$templates[$i] = $template->set('bundle', $name);
|
||||
}
|
||||
|
||||
return $templates;
|
||||
}
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
<?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\CacheWarmer;
|
||||
|
||||
@trigger_error('The '.TemplateFinderInterface::class.' interface is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* Interface for finding all the templates.
|
||||
*
|
||||
* @author Victor Berchet <victor@suumit.com>
|
||||
*
|
||||
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
|
||||
*/
|
||||
interface TemplateFinderInterface
|
||||
{
|
||||
/**
|
||||
* Find all the templates.
|
||||
*
|
||||
* @return array An array of templates of type TemplateReferenceInterface
|
||||
*/
|
||||
public function findAllTemplates();
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
<?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\CacheWarmer;
|
||||
|
||||
@trigger_error('The '.TemplatePathsCacheWarmer::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Templating\Loader\TemplateLocator;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmer;
|
||||
|
||||
/**
|
||||
* Computes the association between template names and their paths on the disk.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
|
||||
*/
|
||||
class TemplatePathsCacheWarmer extends CacheWarmer
|
||||
{
|
||||
protected $finder;
|
||||
protected $locator;
|
||||
|
||||
public function __construct(TemplateFinderInterface $finder, TemplateLocator $locator)
|
||||
{
|
||||
$this->finder = $finder;
|
||||
$this->locator = $locator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Warms up the cache.
|
||||
*
|
||||
* @param string $cacheDir The cache directory
|
||||
*/
|
||||
public function warmUp($cacheDir)
|
||||
{
|
||||
$filesystem = new Filesystem();
|
||||
$templates = [];
|
||||
|
||||
foreach ($this->finder->findAllTemplates() as $template) {
|
||||
$templates[$template->getLogicalName()] = rtrim($filesystem->makePathRelative($this->locator->locate($template), $cacheDir), '/');
|
||||
}
|
||||
|
||||
$templates = str_replace("' => '", "' => __DIR__.'/", var_export($templates, true));
|
||||
|
||||
$this->writeCacheFile($cacheDir.'/templates.php', sprintf("<?php return %s;\n", $templates));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether this warmer is optional or not.
|
||||
*
|
||||
* @return bool always true
|
||||
*/
|
||||
public function isOptional()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
@ -25,7 +25,6 @@ use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInt
|
||||
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
|
||||
use Symfony\Component\Serializer\SerializerInterface;
|
||||
use Symfony\Component\Templating\EngineInterface;
|
||||
use Symfony\Contracts\Service\ServiceSubscriberInterface;
|
||||
use Twig\Environment;
|
||||
|
||||
@ -80,7 +79,6 @@ abstract class AbstractController implements ServiceSubscriberInterface
|
||||
'serializer' => '?'.SerializerInterface::class,
|
||||
'session' => '?'.SessionInterface::class,
|
||||
'security.authorization_checker' => '?'.AuthorizationCheckerInterface::class,
|
||||
'templating' => '?'.EngineInterface::class,
|
||||
'twig' => '?'.Environment::class,
|
||||
'doctrine' => '?'.ManagerRegistry::class,
|
||||
'form.factory' => '?'.FormFactoryInterface::class,
|
||||
|
@ -205,14 +205,8 @@ trait ControllerTrait
|
||||
*/
|
||||
protected function renderView(string $view, array $parameters = []): string
|
||||
{
|
||||
if ($this->container->has('templating')) {
|
||||
@trigger_error('Using the "templating" service is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);
|
||||
|
||||
return $this->container->get('templating')->render($view, $parameters);
|
||||
}
|
||||
|
||||
if (!$this->container->has('twig')) {
|
||||
throw new \LogicException('You can not use the "renderView" method if the Templating Component or the Twig Bundle are not available. Try running "composer require symfony/twig-bundle".');
|
||||
throw new \LogicException('You can not use the "renderView" method if the Twig Bundle are not available. Try running "composer require symfony/twig-bundle".');
|
||||
}
|
||||
|
||||
return $this->container->get('twig')->render($view, $parameters);
|
||||
@ -225,15 +219,7 @@ trait ControllerTrait
|
||||
*/
|
||||
protected function render(string $view, array $parameters = [], Response $response = null): Response
|
||||
{
|
||||
if ($this->container->has('templating')) {
|
||||
@trigger_error('Using the "templating" service is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);
|
||||
|
||||
$content = $this->container->get('templating')->render($view, $parameters);
|
||||
} elseif ($this->container->has('twig')) {
|
||||
$content = $this->container->get('twig')->render($view, $parameters);
|
||||
} else {
|
||||
throw new \LogicException('You can not use the "render" method if the Templating Component or the Twig Bundle are not available. Try running "composer require symfony/twig-bundle".');
|
||||
}
|
||||
$content = $this->renderView($view, $parameters);
|
||||
|
||||
if (null === $response) {
|
||||
$response = new Response();
|
||||
@ -251,24 +237,16 @@ trait ControllerTrait
|
||||
*/
|
||||
protected function stream(string $view, array $parameters = [], StreamedResponse $response = null): StreamedResponse
|
||||
{
|
||||
if ($this->container->has('templating')) {
|
||||
@trigger_error('Using the "templating" service is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);
|
||||
|
||||
$templating = $this->container->get('templating');
|
||||
|
||||
$callback = function () use ($templating, $view, $parameters) {
|
||||
$templating->stream($view, $parameters);
|
||||
};
|
||||
} elseif ($this->container->has('twig')) {
|
||||
$twig = $this->container->get('twig');
|
||||
|
||||
$callback = function () use ($twig, $view, $parameters) {
|
||||
$twig->display($view, $parameters);
|
||||
};
|
||||
} else {
|
||||
throw new \LogicException('You can not use the "stream" method if the Templating Component or the Twig Bundle are not available. Try running "composer require symfony/twig-bundle".');
|
||||
if (!$this->container->has('twig')) {
|
||||
throw new \LogicException('You can not use the "stream" method if the Twig Bundle are not available. Try running "composer require symfony/twig-bundle".');
|
||||
}
|
||||
|
||||
$twig = $this->container->get('twig');
|
||||
|
||||
$callback = function () use ($twig, $view, $parameters) {
|
||||
$twig->display($view, $parameters);
|
||||
};
|
||||
|
||||
if (null === $response) {
|
||||
return new StreamedResponse($callback);
|
||||
}
|
||||
|
@ -12,7 +12,6 @@
|
||||
namespace Symfony\Bundle\FrameworkBundle\Controller;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Templating\EngineInterface;
|
||||
use Twig\Environment;
|
||||
|
||||
/**
|
||||
@ -25,16 +24,10 @@ use Twig\Environment;
|
||||
class TemplateController
|
||||
{
|
||||
private $twig;
|
||||
private $templating;
|
||||
|
||||
public function __construct(Environment $twig = null, EngineInterface $templating = null)
|
||||
public function __construct(Environment $twig = null)
|
||||
{
|
||||
if (null !== $templating) {
|
||||
@trigger_error(sprintf('Using a "%s" instance for "%s" is deprecated since version 4.4; use a \Twig\Environment instance instead.', EngineInterface::class, __CLASS__), E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
$this->twig = $twig;
|
||||
$this->templating = $templating;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -47,14 +40,12 @@ class TemplateController
|
||||
*/
|
||||
public function templateAction(string $template, int $maxAge = null, int $sharedAge = null, bool $private = null): Response
|
||||
{
|
||||
if ($this->templating) {
|
||||
$response = new Response($this->templating->render($template));
|
||||
} elseif ($this->twig) {
|
||||
$response = new Response($this->twig->render($template));
|
||||
} else {
|
||||
throw new \LogicException('You can not use the TemplateController if the Templating Component or the Twig Bundle are not available.');
|
||||
if (null === $this->twig) {
|
||||
throw new \LogicException('You can not use the TemplateController if the Twig Bundle is not available.');
|
||||
}
|
||||
|
||||
$response = new Response($this->twig->render($template));
|
||||
|
||||
if ($maxAge) {
|
||||
$response->setMaxAge($maxAge);
|
||||
}
|
||||
|
@ -1,62 +0,0 @@
|
||||
<?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\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface as FrameworkBundleEngineInterface;
|
||||
use Symfony\Component\DependencyInjection\Alias;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\Templating\EngineInterface as ComponentEngineInterface;
|
||||
|
||||
/**
|
||||
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
|
||||
*/
|
||||
class TemplatingPass implements CompilerPassInterface
|
||||
{
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
if ($container->hasDefinition('templating')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($container->hasAlias('templating')) {
|
||||
$container->setAlias(ComponentEngineInterface::class, new Alias('templating', false));
|
||||
$container->setAlias(FrameworkBundleEngineInterface::class, new Alias('templating', false));
|
||||
}
|
||||
|
||||
if ($container->hasDefinition('templating.engine.php')) {
|
||||
$refs = [];
|
||||
$helpers = [];
|
||||
|
||||
foreach ($container->findTaggedServiceIds('templating.helper', true) as $id => $attributes) {
|
||||
if (!$container->getDefinition($id)->isDeprecated()) {
|
||||
@trigger_error('The "templating.helper" tag is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
if (isset($attributes[0]['alias'])) {
|
||||
$helpers[$attributes[0]['alias']] = $id;
|
||||
$refs[$id] = new Reference($id);
|
||||
}
|
||||
}
|
||||
|
||||
if (\count($helpers) > 0) {
|
||||
$definition = $container->getDefinition('templating.engine.php');
|
||||
$definition->addMethodCall('setHelpers', [$helpers]);
|
||||
|
||||
if ($container->hasDefinition('templating.engine.php.helpers_locator')) {
|
||||
$container->getDefinition('templating.engine.php.helpers_locator')->replaceArgument(0, $refs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -54,7 +54,6 @@ class UnusedTagsPass implements CompilerPassInterface
|
||||
'security.voter',
|
||||
'serializer.encoder',
|
||||
'serializer.normalizer',
|
||||
'templating.helper',
|
||||
'translation.dumper',
|
||||
'translation.extractor',
|
||||
'translation.loader',
|
||||
|
@ -28,7 +28,6 @@ use Symfony\Component\Lock\Store\SemaphoreStore;
|
||||
use Symfony\Component\Mailer\Mailer;
|
||||
use Symfony\Component\Messenger\MessageBusInterface;
|
||||
use Symfony\Component\PropertyInfo\PropertyInfoExtractorInterface;
|
||||
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
|
||||
use Symfony\Component\Serializer\Serializer;
|
||||
use Symfony\Component\Translation\Translator;
|
||||
use Symfony\Component\Validator\Validation;
|
||||
@ -97,7 +96,6 @@ class Configuration implements ConfigurationInterface
|
||||
$this->addRouterSection($rootNode);
|
||||
$this->addSessionSection($rootNode);
|
||||
$this->addRequestSection($rootNode);
|
||||
$this->addTemplatingSection($rootNode);
|
||||
$this->addAssetsSection($rootNode);
|
||||
$this->addTranslatorSection($rootNode);
|
||||
$this->addValidationSection($rootNode);
|
||||
@ -598,66 +596,6 @@ class Configuration implements ConfigurationInterface
|
||||
;
|
||||
}
|
||||
|
||||
private function addTemplatingSection(ArrayNodeDefinition $rootNode)
|
||||
{
|
||||
$rootNode
|
||||
->children()
|
||||
->arrayNode('templating')
|
||||
->info('templating configuration')
|
||||
->canBeEnabled()
|
||||
->beforeNormalization()
|
||||
->ifTrue(function ($v) { return false === $v || \is_array($v) && false === $v['enabled']; })
|
||||
->then(function () { return ['enabled' => false, 'engines' => false]; })
|
||||
->end()
|
||||
->children()
|
||||
->scalarNode('hinclude_default_template')->setDeprecated('Setting "templating.hinclude_default_template" is deprecated since Symfony 4.3, use "fragments.hinclude_default_template" instead.')->defaultNull()->end()
|
||||
->scalarNode('cache')->end()
|
||||
->arrayNode('form')
|
||||
->addDefaultsIfNotSet()
|
||||
->fixXmlConfig('resource')
|
||||
->children()
|
||||
->arrayNode('resources')
|
||||
->addDefaultChildrenIfNoneSet()
|
||||
->prototype('scalar')->defaultValue('FrameworkBundle:Form')->end()
|
||||
->validate()
|
||||
->ifTrue(function ($v) {return !\in_array('FrameworkBundle:Form', $v); })
|
||||
->then(function ($v) {
|
||||
return array_merge(['FrameworkBundle:Form'], $v);
|
||||
})
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->fixXmlConfig('engine')
|
||||
->children()
|
||||
->arrayNode('engines')
|
||||
->example(['twig'])
|
||||
->isRequired()
|
||||
->requiresAtLeastOneElement()
|
||||
->canBeUnset()
|
||||
->beforeNormalization()
|
||||
->ifTrue(function ($v) { return !\is_array($v) && false !== $v; })
|
||||
->then(function ($v) { return [$v]; })
|
||||
->end()
|
||||
->prototype('scalar')->end()
|
||||
->end()
|
||||
->end()
|
||||
->fixXmlConfig('loader')
|
||||
->children()
|
||||
->arrayNode('loaders')
|
||||
->beforeNormalization()
|
||||
->ifTrue(function ($v) { return !\is_array($v); })
|
||||
->then(function ($v) { return [$v]; })
|
||||
->end()
|
||||
->prototype('scalar')->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
;
|
||||
}
|
||||
|
||||
private function addAssetsSection(ArrayNodeDefinition $rootNode)
|
||||
{
|
||||
$rootNode
|
||||
|
@ -197,23 +197,20 @@ class FrameworkExtension extends Extension
|
||||
$container->setParameter('kernel.default_locale', $config['default_locale']);
|
||||
|
||||
if (!$container->hasParameter('debug.file_link_format')) {
|
||||
if (!$container->hasParameter('templating.helper.code.file_link_format')) {
|
||||
$links = [
|
||||
'textmate' => 'txmt://open?url=file://%%f&line=%%l',
|
||||
'macvim' => 'mvim://open?url=file://%%f&line=%%l',
|
||||
'emacs' => 'emacs://open?url=file://%%f&line=%%l',
|
||||
'sublime' => 'subl://open?url=file://%%f&line=%%l',
|
||||
'phpstorm' => 'phpstorm://open?file=%%f&line=%%l',
|
||||
'atom' => 'atom://core/open/file?filename=%%f&line=%%l',
|
||||
'vscode' => 'vscode://file/%%f:%%l',
|
||||
];
|
||||
$ide = $config['ide'];
|
||||
// mark any env vars found in the ide setting as used
|
||||
$container->resolveEnvPlaceholders($ide);
|
||||
$links = [
|
||||
'textmate' => 'txmt://open?url=file://%%f&line=%%l',
|
||||
'macvim' => 'mvim://open?url=file://%%f&line=%%l',
|
||||
'emacs' => 'emacs://open?url=file://%%f&line=%%l',
|
||||
'sublime' => 'subl://open?url=file://%%f&line=%%l',
|
||||
'phpstorm' => 'phpstorm://open?file=%%f&line=%%l',
|
||||
'atom' => 'atom://core/open/file?filename=%%f&line=%%l',
|
||||
'vscode' => 'vscode://file/%%f:%%l',
|
||||
];
|
||||
$ide = $config['ide'];
|
||||
// mark any env vars found in the ide setting as used
|
||||
$container->resolveEnvPlaceholders($ide);
|
||||
|
||||
$container->setParameter('templating.helper.code.file_link_format', str_replace('%', '%%', ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format')) ?: (isset($links[$ide]) ? $links[$ide] : $ide));
|
||||
}
|
||||
$container->setParameter('debug.file_link_format', '%templating.helper.code.file_link_format%');
|
||||
$container->setParameter('debug.file_link_format', str_replace('%', '%%', ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format')) ?: (isset($links[$ide]) ? $links[$ide] : $ide));
|
||||
}
|
||||
|
||||
if (!empty($config['test'])) {
|
||||
@ -269,16 +266,6 @@ class FrameworkExtension extends Extension
|
||||
$this->registerAssetsConfiguration($config['assets'], $container, $loader);
|
||||
}
|
||||
|
||||
if ($this->isConfigEnabled($container, $config['templating'])) {
|
||||
@trigger_error('Enabling the Templating component is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);
|
||||
|
||||
if (!class_exists('Symfony\Component\Templating\PhpEngine')) {
|
||||
throw new LogicException('Templating support cannot be enabled as the Templating component is not installed. Try running "composer require symfony/templating".');
|
||||
}
|
||||
|
||||
$this->registerTemplatingConfiguration($config['templating'], $container, $loader);
|
||||
}
|
||||
|
||||
if ($this->messengerConfigEnabled = $this->isConfigEnabled($container, $config['messenger'])) {
|
||||
$this->registerMessengerConfiguration($config['messenger'], $container, $loader, $config['serializer'], $config['validation']);
|
||||
} else {
|
||||
@ -494,9 +481,6 @@ class FrameworkExtension extends Extension
|
||||
|
||||
return;
|
||||
}
|
||||
if ($container->hasParameter('fragment.renderer.hinclude.global_template') && null !== $container->getParameter('fragment.renderer.hinclude.global_template') && null !== $config['hinclude_default_template']) {
|
||||
throw new \LogicException('You cannot set both "templating.hinclude_default_template" and "fragments.hinclude_default_template", please only use "fragments.hinclude_default_template".');
|
||||
}
|
||||
|
||||
$container->setParameter('fragment.renderer.hinclude.global_template', $config['hinclude_default_template']);
|
||||
|
||||
@ -913,85 +897,6 @@ class FrameworkExtension extends Extension
|
||||
}
|
||||
}
|
||||
|
||||
private function registerTemplatingConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
|
||||
{
|
||||
$loader->load('templating.xml');
|
||||
|
||||
$container->setParameter('fragment.renderer.hinclude.global_template', $config['hinclude_default_template']);
|
||||
|
||||
if ($container->getParameter('kernel.debug')) {
|
||||
$logger = new Reference('logger', ContainerInterface::IGNORE_ON_INVALID_REFERENCE);
|
||||
|
||||
$container->getDefinition('templating.loader.cache')
|
||||
->addTag('monolog.logger', ['channel' => 'templating'])
|
||||
->addMethodCall('setLogger', [$logger]);
|
||||
$container->getDefinition('templating.loader.chain')
|
||||
->addTag('monolog.logger', ['channel' => 'templating'])
|
||||
->addMethodCall('setLogger', [$logger]);
|
||||
}
|
||||
|
||||
if (!empty($config['loaders'])) {
|
||||
$loaders = array_map(function ($loader) { return new Reference($loader); }, $config['loaders']);
|
||||
|
||||
// Use a delegation unless only a single loader was registered
|
||||
if (1 === \count($loaders)) {
|
||||
$container->setAlias('templating.loader', (string) reset($loaders))->setPrivate(true);
|
||||
} else {
|
||||
$container->getDefinition('templating.loader.chain')->addArgument($loaders);
|
||||
$container->setAlias('templating.loader', 'templating.loader.chain')->setPrivate(true);
|
||||
}
|
||||
}
|
||||
|
||||
$container->setParameter('templating.loader.cache.path', null);
|
||||
if (isset($config['cache'])) {
|
||||
// Wrap the existing loader with cache (must happen after loaders are registered)
|
||||
$container->setDefinition('templating.loader.wrapped', $container->findDefinition('templating.loader'));
|
||||
$loaderCache = $container->getDefinition('templating.loader.cache');
|
||||
$container->setParameter('templating.loader.cache.path', $config['cache']);
|
||||
|
||||
$container->setDefinition('templating.loader', $loaderCache);
|
||||
}
|
||||
|
||||
$container->setParameter('templating.engines', $config['engines']);
|
||||
$engines = array_map(function ($engine) { return new Reference('templating.engine.'.$engine); }, $config['engines']);
|
||||
|
||||
// Use a delegation unless only a single engine was registered
|
||||
if (1 === \count($engines)) {
|
||||
$container->setAlias('templating', (string) reset($engines))->setPublic(true);
|
||||
} else {
|
||||
$templateEngineDefinition = $container->getDefinition('templating.engine.delegating');
|
||||
foreach ($engines as $engine) {
|
||||
$templateEngineDefinition->addMethodCall('addEngine', [$engine]);
|
||||
}
|
||||
$container->setAlias('templating', 'templating.engine.delegating')->setPublic(true);
|
||||
}
|
||||
|
||||
$container->getDefinition('fragment.renderer.hinclude')
|
||||
->addTag('kernel.fragment_renderer', ['alias' => 'hinclude'])
|
||||
->replaceArgument(0, new Reference('templating'))
|
||||
;
|
||||
|
||||
// configure the PHP engine if needed
|
||||
if (\in_array('php', $config['engines'], true)) {
|
||||
$loader->load('templating_php.xml');
|
||||
|
||||
$container->setParameter('templating.helper.form.resources', $config['form']['resources']);
|
||||
|
||||
if ($container->getParameter('kernel.debug') && class_exists(Stopwatch::class)) {
|
||||
$loader->load('templating_debug.xml');
|
||||
|
||||
$container->setDefinition('templating.engine.php', $container->findDefinition('debug.templating.engine.php'));
|
||||
$container->setAlias('debug.templating.engine.php', 'templating.engine.php')->setPrivate(true);
|
||||
}
|
||||
|
||||
if ($container->has('assets.packages')) {
|
||||
$container->getDefinition('templating.helper.assets')->replaceArgument(0, new Reference('assets.packages'));
|
||||
} else {
|
||||
$container->removeDefinition('templating.helper.assets');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function registerAssetsConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
|
||||
{
|
||||
$loader->load('assets.xml');
|
||||
|
@ -18,7 +18,6 @@ use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ContainerBuilder
|
||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\DataCollectorTranslatorPass;
|
||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\LoggingTranslatorPass;
|
||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ProfilerPass;
|
||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TemplatingPass;
|
||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TestServiceContainerRealRefPass;
|
||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TestServiceContainerWeakRefPass;
|
||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\UnusedTagsPass;
|
||||
@ -98,7 +97,6 @@ class FrameworkBundle extends Bundle
|
||||
// must be registered before removing private services as some might be listeners/subscribers
|
||||
// but as late as possible to get resolved parameters
|
||||
$container->addCompilerPass((new RegisterListenersPass())->setHotPathEvents($hotPathEvents), PassConfig::TYPE_BEFORE_REMOVING);
|
||||
$container->addCompilerPass(new TemplatingPass());
|
||||
$this->addCompilerPassIfExists($container, AddConstraintValidatorsPass::class);
|
||||
$container->addCompilerPass(new AddAnnotationsCachedReaderPass(), PassConfig::TYPE_AFTER_REMOVING, -255);
|
||||
$this->addCompilerPassIfExists($container, AddValidatorInitializersPass::class);
|
||||
|
@ -26,7 +26,7 @@
|
||||
</service>
|
||||
|
||||
<service id="fragment.renderer.hinclude" class="Symfony\Component\HttpKernel\Fragment\HIncludeFragmentRenderer">
|
||||
<argument /> <!-- templating or Twig service -->
|
||||
<argument type="service" id="twig" on-invalid="null" />
|
||||
<argument type="service" id="uri_signer" />
|
||||
<argument>%fragment.renderer.hinclude.global_template%</argument>
|
||||
<call method="setFragmentPath"><argument>%fragment.path%</argument></call>
|
||||
|
@ -114,7 +114,6 @@
|
||||
|
||||
<service id="Symfony\Bundle\FrameworkBundle\Controller\TemplateController" public="true">
|
||||
<argument type="service" id="twig" on-invalid="ignore" />
|
||||
<argument type="service" id="templating" on-invalid="ignore" />
|
||||
</service>
|
||||
</services>
|
||||
</container>
|
||||
|
@ -20,7 +20,6 @@
|
||||
<xsd:element name="router" type="router" minOccurs="0" maxOccurs="1" />
|
||||
<xsd:element name="session" type="session" minOccurs="0" maxOccurs="1" />
|
||||
<xsd:element name="request" type="request" minOccurs="0" maxOccurs="1" />
|
||||
<xsd:element name="templating" type="templating" minOccurs="0" maxOccurs="1" />
|
||||
<xsd:element name="translator" type="translator" minOccurs="0" maxOccurs="1" />
|
||||
<xsd:element name="validation" type="validation" minOccurs="0" maxOccurs="1" />
|
||||
<xsd:element name="annotations" type="annotations" minOccurs="0" maxOccurs="1" />
|
||||
@ -158,18 +157,6 @@
|
||||
<xsd:attribute name="json-manifest-path" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="templating">
|
||||
<xsd:sequence>
|
||||
<xsd:element name="loader" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
|
||||
<xsd:element name="engine" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
|
||||
<xsd:element name="form" type="form-resources" minOccurs="0" maxOccurs="1" />
|
||||
</xsd:sequence>
|
||||
|
||||
<xsd:attribute name="enabled" type="xsd:boolean" />
|
||||
<xsd:attribute name="cache" type="xsd:string" />
|
||||
<xsd:attribute name="hinclude-default-template" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="form-resources">
|
||||
<xsd:choice minOccurs="1" maxOccurs="unbounded">
|
||||
<xsd:element name="resource" type="xsd:string" />
|
||||
|
@ -1,67 +0,0 @@
|
||||
<?xml version="1.0" ?>
|
||||
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||
|
||||
<services>
|
||||
<defaults public="false" />
|
||||
|
||||
<service id="templating.engine.delegating" class="Symfony\Bundle\FrameworkBundle\Templating\DelegatingEngine">
|
||||
<argument type="service" id="service_container" />
|
||||
<argument type="collection" /> <!-- engines -->
|
||||
|
||||
<deprecated>The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0.</deprecated>
|
||||
</service>
|
||||
|
||||
<service id="templating.name_parser" class="Symfony\Bundle\FrameworkBundle\Templating\TemplateNameParser">
|
||||
<argument type="service" id="kernel" />
|
||||
|
||||
<deprecated>The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0.</deprecated>
|
||||
</service>
|
||||
|
||||
<service id="templating.filename_parser" class="Symfony\Bundle\FrameworkBundle\Templating\TemplateFilenameParser" />
|
||||
|
||||
<service id="templating.locator" class="Symfony\Bundle\FrameworkBundle\Templating\Loader\TemplateLocator">
|
||||
<argument type="service" id="file_locator" />
|
||||
<argument>%kernel.cache_dir%</argument>
|
||||
|
||||
<deprecated>The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0.</deprecated>
|
||||
</service>
|
||||
|
||||
<service id="templating.finder" class="Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplateFinder">
|
||||
<argument type="service" id="kernel" />
|
||||
<argument type="service" id="templating.filename_parser" />
|
||||
<argument>%kernel.root_dir%/Resources</argument>
|
||||
|
||||
<deprecated>The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0.</deprecated>
|
||||
</service>
|
||||
|
||||
<service id="templating.cache_warmer.template_paths" class="Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplatePathsCacheWarmer">
|
||||
<tag name="kernel.cache_warmer" priority="20" />
|
||||
<argument type="service" id="templating.finder" />
|
||||
<argument type="service" id="templating.locator" />
|
||||
|
||||
<deprecated>The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0.</deprecated>
|
||||
</service>
|
||||
|
||||
<service id="templating.loader.filesystem" class="Symfony\Bundle\FrameworkBundle\Templating\Loader\FilesystemLoader">
|
||||
<argument type="service" id="templating.locator" />
|
||||
|
||||
<deprecated>The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0.</deprecated>
|
||||
</service>
|
||||
|
||||
<service id="templating.loader.cache" class="Symfony\Component\Templating\Loader\CacheLoader">
|
||||
<argument type="service" id="templating.loader.wrapped" />
|
||||
<argument>%templating.loader.cache.path%</argument>
|
||||
|
||||
<deprecated>The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0.</deprecated>
|
||||
</service>
|
||||
|
||||
<service id="templating.loader.chain" class="Symfony\Component\Templating\Loader\ChainLoader">
|
||||
<deprecated>The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0.</deprecated>
|
||||
</service>
|
||||
|
||||
<service id="templating.loader" alias="templating.loader.filesystem" public="true" />
|
||||
</services>
|
||||
</container>
|
@ -1,21 +0,0 @@
|
||||
<?xml version="1.0" ?>
|
||||
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||
|
||||
<services>
|
||||
<defaults public="false" />
|
||||
|
||||
<service id="debug.templating.engine.php" class="Symfony\Bundle\FrameworkBundle\Templating\TimedPhpEngine">
|
||||
<argument type="service" id="templating.name_parser" />
|
||||
<argument type="service" id="templating.engine.php.helpers_locator" />
|
||||
<argument type="service" id="templating.loader" />
|
||||
<argument type="service" id="debug.stopwatch" />
|
||||
<argument type="service" id="templating.globals" />
|
||||
<call method="setCharset"><argument>%kernel.charset%</argument></call>
|
||||
|
||||
<deprecated>The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0.</deprecated>
|
||||
</service>
|
||||
</services>
|
||||
</container>
|
@ -1,116 +0,0 @@
|
||||
<?xml version="1.0" ?>
|
||||
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||
|
||||
<services>
|
||||
<defaults public="false" />
|
||||
|
||||
<service id="templating.engine.php" class="Symfony\Bundle\FrameworkBundle\Templating\PhpEngine">
|
||||
<argument type="service" id="templating.name_parser" />
|
||||
<argument type="service" id="templating.engine.php.helpers_locator" />
|
||||
<argument type="service" id="templating.loader" />
|
||||
<argument type="service" id="templating.globals" />
|
||||
<call method="setCharset"><argument>%kernel.charset%</argument></call>
|
||||
|
||||
<deprecated>The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0.</deprecated>
|
||||
</service>
|
||||
|
||||
<service id="templating.engine.php.helpers_locator">
|
||||
<tag name="container.service_locator" />
|
||||
<argument type="collection" />
|
||||
</service>
|
||||
|
||||
<service id="templating.helper.slots" class="Symfony\Component\Templating\Helper\SlotsHelper">
|
||||
<tag name="templating.helper" alias="slots" />
|
||||
|
||||
<deprecated>The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0.</deprecated>
|
||||
</service>
|
||||
|
||||
<service id="templating.helper.request" class="Symfony\Bundle\FrameworkBundle\Templating\Helper\RequestHelper">
|
||||
<tag name="templating.helper" alias="request" />
|
||||
<argument type="service" id="request_stack" />
|
||||
|
||||
<deprecated>The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0.</deprecated>
|
||||
</service>
|
||||
|
||||
<service id="templating.helper.session" class="Symfony\Bundle\FrameworkBundle\Templating\Helper\SessionHelper">
|
||||
<tag name="templating.helper" alias="session" />
|
||||
<argument type="service" id="request_stack" />
|
||||
|
||||
<deprecated>The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0.</deprecated>
|
||||
</service>
|
||||
|
||||
<service id="templating.helper.router" class="Symfony\Bundle\FrameworkBundle\Templating\Helper\RouterHelper">
|
||||
<tag name="templating.helper" alias="router" />
|
||||
<argument type="service" id="router" />
|
||||
|
||||
<deprecated>The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0.</deprecated>
|
||||
</service>
|
||||
|
||||
<service id="templating.helper.assets" class="Symfony\Bundle\FrameworkBundle\Templating\Helper\AssetsHelper">
|
||||
<tag name="templating.helper" alias="assets" />
|
||||
<argument /> <!-- packages -->
|
||||
|
||||
<deprecated>The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0.</deprecated>
|
||||
</service>
|
||||
|
||||
<service id="templating.helper.actions" class="Symfony\Bundle\FrameworkBundle\Templating\Helper\ActionsHelper">
|
||||
<tag name="templating.helper" alias="actions" />
|
||||
<argument type="service" id="fragment.handler" />
|
||||
|
||||
<deprecated>The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0.</deprecated>
|
||||
</service>
|
||||
|
||||
<service id="templating.helper.code" class="Symfony\Bundle\FrameworkBundle\Templating\Helper\CodeHelper">
|
||||
<tag name="templating.helper" alias="code" />
|
||||
<argument type="service" id="debug.file_link_formatter"></argument>
|
||||
<argument>%kernel.project_dir%</argument>
|
||||
<argument>%kernel.charset%</argument>
|
||||
|
||||
<deprecated>The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0.</deprecated>
|
||||
</service>
|
||||
|
||||
<service id="templating.helper.translator" class="Symfony\Bundle\FrameworkBundle\Templating\Helper\TranslatorHelper">
|
||||
<tag name="templating.helper" alias="translator" />
|
||||
<argument type="service" id="translator" on-invalid="null" />
|
||||
|
||||
<deprecated>The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0.</deprecated>
|
||||
</service>
|
||||
|
||||
<service id="templating.helper.form" class="Symfony\Bundle\FrameworkBundle\Templating\Helper\FormHelper">
|
||||
<tag name="templating.helper" alias="form" />
|
||||
<argument type="service" id="templating.form.renderer" />
|
||||
|
||||
<deprecated>The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0.</deprecated>
|
||||
</service>
|
||||
|
||||
<service id="templating.helper.stopwatch" class="Symfony\Bundle\FrameworkBundle\Templating\Helper\StopwatchHelper">
|
||||
<tag name="templating.helper" alias="stopwatch" />
|
||||
<argument type="service" id="debug.stopwatch" on-invalid="ignore" />
|
||||
|
||||
<deprecated>The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0.</deprecated>
|
||||
</service>
|
||||
|
||||
<service id="templating.form.engine" class="Symfony\Component\Form\Extension\Templating\TemplatingRendererEngine">
|
||||
<argument type="service" id="templating.engine.php" />
|
||||
<argument>%templating.helper.form.resources%</argument>
|
||||
|
||||
<deprecated>The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0.</deprecated>
|
||||
</service>
|
||||
|
||||
<service id="templating.form.renderer" class="Symfony\Component\Form\FormRenderer">
|
||||
<argument type="service" id="templating.form.engine" />
|
||||
<argument type="service" id="security.csrf.token_manager" on-invalid="null" />
|
||||
|
||||
<deprecated>The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0.</deprecated>
|
||||
</service>
|
||||
|
||||
<service id="templating.globals" class="Symfony\Bundle\FrameworkBundle\Templating\GlobalVariables">
|
||||
<argument type="service" id="service_container" />
|
||||
|
||||
<deprecated>The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0.</deprecated>
|
||||
</service>
|
||||
</services>
|
||||
</container>
|
@ -1,78 +0,0 @@
|
||||
<?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\Templating;
|
||||
|
||||
@trigger_error('The '.DelegatingEngine::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);
|
||||
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Templating\DelegatingEngine as BaseDelegatingEngine;
|
||||
|
||||
/**
|
||||
* DelegatingEngine selects an engine for a given template.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
|
||||
*/
|
||||
class DelegatingEngine extends BaseDelegatingEngine implements EngineInterface
|
||||
{
|
||||
protected $container;
|
||||
|
||||
public function __construct(ContainerInterface $container, array $engineIds)
|
||||
{
|
||||
$this->container = $container;
|
||||
$this->engines = $engineIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getEngine($name)
|
||||
{
|
||||
$this->resolveEngines();
|
||||
|
||||
return parent::getEngine($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function renderResponse($view, array $parameters = [], Response $response = null)
|
||||
{
|
||||
$engine = $this->getEngine($view);
|
||||
|
||||
if ($engine instanceof EngineInterface) {
|
||||
return $engine->renderResponse($view, $parameters, $response);
|
||||
}
|
||||
|
||||
if (null === $response) {
|
||||
$response = new Response();
|
||||
}
|
||||
|
||||
$response->setContent($engine->render($view, $parameters));
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolved engine ids to their real engine instances from the container.
|
||||
*/
|
||||
private function resolveEngines()
|
||||
{
|
||||
foreach ($this->engines as $i => $engine) {
|
||||
if (\is_string($engine)) {
|
||||
$this->engines[$i] = $this->container->get($engine);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
<?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\Templating;
|
||||
|
||||
@trigger_error('The '.EngineInterface::class.' interface is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Templating\EngineInterface as BaseEngineInterface;
|
||||
|
||||
/**
|
||||
* EngineInterface is the interface each engine must implement.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
|
||||
*/
|
||||
interface EngineInterface extends BaseEngineInterface
|
||||
{
|
||||
/**
|
||||
* Renders a view and returns a Response.
|
||||
*
|
||||
* @param string $view The view name
|
||||
* @param array $parameters An array of parameters to pass to the view
|
||||
* @param Response $response A Response instance
|
||||
*
|
||||
* @return Response A Response instance
|
||||
*
|
||||
* @throws \RuntimeException if the template cannot be rendered
|
||||
*/
|
||||
public function renderResponse($view, array $parameters = [], Response $response = null);
|
||||
}
|
@ -1,98 +0,0 @@
|
||||
<?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\Templating;
|
||||
|
||||
@trigger_error('The '.GlobalVariables::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Session\Session;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
|
||||
/**
|
||||
* GlobalVariables is the entry point for Symfony global variables in PHP templates.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
|
||||
*/
|
||||
class GlobalVariables
|
||||
{
|
||||
protected $container;
|
||||
|
||||
public function __construct(ContainerInterface $container)
|
||||
{
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TokenInterface|null
|
||||
*/
|
||||
public function getToken()
|
||||
{
|
||||
if (!$this->container->has('security.token_storage')) {
|
||||
return;
|
||||
}
|
||||
|
||||
return $this->container->get('security.token_storage')->getToken();
|
||||
}
|
||||
|
||||
public function getUser()
|
||||
{
|
||||
if (!$token = $this->getToken()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$user = $token->getUser();
|
||||
if (!\is_object($user)) {
|
||||
return;
|
||||
}
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Request|null The HTTP request object
|
||||
*/
|
||||
public function getRequest()
|
||||
{
|
||||
if ($this->container->has('request_stack')) {
|
||||
return $this->container->get('request_stack')->getCurrentRequest();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Session|null The session
|
||||
*/
|
||||
public function getSession()
|
||||
{
|
||||
if ($request = $this->getRequest()) {
|
||||
return $request->getSession();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string The current environment string (e.g 'dev')
|
||||
*/
|
||||
public function getEnvironment()
|
||||
{
|
||||
return $this->container->getParameter('kernel.environment');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool The current debug mode
|
||||
*/
|
||||
public function getDebug()
|
||||
{
|
||||
return (bool) $this->container->getParameter('kernel.debug');
|
||||
}
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
<?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\Templating\Helper;
|
||||
|
||||
@trigger_error('The '.ActionsHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\HttpKernel\Controller\ControllerReference;
|
||||
use Symfony\Component\HttpKernel\Fragment\FragmentHandler;
|
||||
use Symfony\Component\Templating\Helper\Helper;
|
||||
|
||||
/**
|
||||
* ActionsHelper manages action inclusions.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
|
||||
*/
|
||||
class ActionsHelper extends Helper
|
||||
{
|
||||
private $handler;
|
||||
|
||||
public function __construct(FragmentHandler $handler)
|
||||
{
|
||||
$this->handler = $handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the fragment content for a given URI.
|
||||
*
|
||||
* @param string $uri A URI
|
||||
* @param array $options An array of options
|
||||
*
|
||||
* @return string The fragment content
|
||||
*
|
||||
* @see FragmentHandler::render()
|
||||
*/
|
||||
public function render($uri, array $options = [])
|
||||
{
|
||||
$strategy = isset($options['strategy']) ? $options['strategy'] : 'inline';
|
||||
unset($options['strategy']);
|
||||
|
||||
return $this->handler->render($uri, $strategy, $options);
|
||||
}
|
||||
|
||||
public function controller($controller, $attributes = [], $query = [])
|
||||
{
|
||||
return new ControllerReference($controller, $attributes, $query);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'actions';
|
||||
}
|
||||
}
|
@ -1,71 +0,0 @@
|
||||
<?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\Templating\Helper;
|
||||
|
||||
@trigger_error('The '.AssetsHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\Asset\Packages;
|
||||
use Symfony\Component\Templating\Helper\Helper;
|
||||
|
||||
/**
|
||||
* AssetsHelper helps manage asset URLs.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
|
||||
*/
|
||||
class AssetsHelper extends Helper
|
||||
{
|
||||
private $packages;
|
||||
|
||||
public function __construct(Packages $packages)
|
||||
{
|
||||
$this->packages = $packages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the public url/path of an asset.
|
||||
*
|
||||
* If the package used to generate the path is an instance of
|
||||
* UrlPackage, you will always get a URL and not a path.
|
||||
*
|
||||
* @param string $path A public path
|
||||
* @param string $packageName The name of the asset package to use
|
||||
*
|
||||
* @return string The public path of the asset
|
||||
*/
|
||||
public function getUrl($path, $packageName = null)
|
||||
{
|
||||
return $this->packages->getUrl($path, $packageName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the version of an asset.
|
||||
*
|
||||
* @param string $path A public path
|
||||
* @param string $packageName The name of the asset package to use
|
||||
*
|
||||
* @return string The asset version
|
||||
*/
|
||||
public function getVersion($path, $packageName = null)
|
||||
{
|
||||
return $this->packages->getVersion($path, $packageName);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'assets';
|
||||
}
|
||||
}
|
@ -1,231 +0,0 @@
|
||||
<?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\Templating\Helper;
|
||||
|
||||
@trigger_error('The '.CodeHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\HttpKernel\Debug\FileLinkFormatter;
|
||||
use Symfony\Component\Templating\Helper\Helper;
|
||||
|
||||
/**
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @internal since Symfony 4.2
|
||||
*
|
||||
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
|
||||
*/
|
||||
class CodeHelper extends Helper
|
||||
{
|
||||
protected $fileLinkFormat;
|
||||
protected $rootDir; // to be renamed $projectDir in 5.0
|
||||
protected $charset;
|
||||
|
||||
/**
|
||||
* @param string|FileLinkFormatter $fileLinkFormat The format for links to source files
|
||||
* @param string $projectDir The project root directory
|
||||
* @param string $charset The charset
|
||||
*/
|
||||
public function __construct($fileLinkFormat, string $projectDir, string $charset)
|
||||
{
|
||||
$this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
|
||||
$this->rootDir = str_replace('\\', '/', $projectDir).'/';
|
||||
$this->charset = $charset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats an array as a string.
|
||||
*
|
||||
* @param array $args The argument array
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function formatArgsAsText(array $args)
|
||||
{
|
||||
return strip_tags($this->formatArgs($args));
|
||||
}
|
||||
|
||||
public function abbrClass($class)
|
||||
{
|
||||
$parts = explode('\\', $class);
|
||||
$short = array_pop($parts);
|
||||
|
||||
return sprintf('<abbr title="%s">%s</abbr>', $class, $short);
|
||||
}
|
||||
|
||||
public function abbrMethod($method)
|
||||
{
|
||||
if (false !== strpos($method, '::')) {
|
||||
list($class, $method) = explode('::', $method, 2);
|
||||
$result = sprintf('%s::%s()', $this->abbrClass($class), $method);
|
||||
} elseif ('Closure' === $method) {
|
||||
$result = sprintf('<abbr title="%s">%1$s</abbr>', $method);
|
||||
} else {
|
||||
$result = sprintf('<abbr title="%s">%1$s</abbr>()', $method);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats an array as a string.
|
||||
*
|
||||
* @param array $args The argument array
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function formatArgs(array $args)
|
||||
{
|
||||
$result = [];
|
||||
foreach ($args as $key => $item) {
|
||||
if ('object' === $item[0]) {
|
||||
$parts = explode('\\', $item[1]);
|
||||
$short = array_pop($parts);
|
||||
$formattedValue = sprintf('<em>object</em>(<abbr title="%s">%s</abbr>)', $item[1], $short);
|
||||
} elseif ('array' === $item[0]) {
|
||||
$formattedValue = sprintf('<em>array</em>(%s)', \is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]);
|
||||
} elseif ('string' === $item[0]) {
|
||||
$formattedValue = sprintf("'%s'", htmlspecialchars($item[1], ENT_QUOTES, $this->getCharset()));
|
||||
} elseif ('null' === $item[0]) {
|
||||
$formattedValue = '<em>null</em>';
|
||||
} elseif ('boolean' === $item[0]) {
|
||||
$formattedValue = '<em>'.strtolower(var_export($item[1], true)).'</em>';
|
||||
} elseif ('resource' === $item[0]) {
|
||||
$formattedValue = '<em>resource</em>';
|
||||
} else {
|
||||
$formattedValue = str_replace("\n", '', var_export(htmlspecialchars((string) $item[1], ENT_QUOTES, $this->getCharset()), true));
|
||||
}
|
||||
|
||||
$result[] = \is_int($key) ? $formattedValue : sprintf("'%s' => %s", $key, $formattedValue);
|
||||
}
|
||||
|
||||
return implode(', ', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an excerpt of a code file around the given line number.
|
||||
*
|
||||
* @param string $file A file path
|
||||
* @param int $line The selected line number
|
||||
*
|
||||
* @return string An HTML string
|
||||
*/
|
||||
public function fileExcerpt($file, $line)
|
||||
{
|
||||
if (is_readable($file)) {
|
||||
if (\extension_loaded('fileinfo')) {
|
||||
$finfo = new \finfo();
|
||||
|
||||
// Check if the file is an application/octet-stream (eg. Phar file) because highlight_file cannot parse these files
|
||||
if ('application/octet-stream' === $finfo->file($file, FILEINFO_MIME_TYPE)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// highlight_file could throw warnings
|
||||
// see https://bugs.php.net/bug.php?id=25725
|
||||
$code = @highlight_file($file, true);
|
||||
// remove main code/span tags
|
||||
$code = preg_replace('#^<code.*?>\s*<span.*?>(.*)</span>\s*</code>#s', '\\1', $code);
|
||||
$content = explode('<br />', $code);
|
||||
|
||||
$lines = [];
|
||||
for ($i = max($line - 3, 1), $max = min($line + 3, \count($content)); $i <= $max; ++$i) {
|
||||
$lines[] = '<li'.($i == $line ? ' class="selected"' : '').'><code>'.self::fixCodeMarkup($content[$i - 1]).'</code></li>';
|
||||
}
|
||||
|
||||
return '<ol start="'.max($line - 3, 1).'">'.implode("\n", $lines).'</ol>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a file path.
|
||||
*
|
||||
* @param string $file An absolute file path
|
||||
* @param int $line The line number
|
||||
* @param string $text Use this text for the link rather than the file path
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function formatFile($file, $line, $text = null)
|
||||
{
|
||||
$flags = ENT_QUOTES | ENT_SUBSTITUTE;
|
||||
|
||||
if (null === $text) {
|
||||
$file = trim($file);
|
||||
$fileStr = $file;
|
||||
if (0 === strpos($fileStr, $this->rootDir)) {
|
||||
$fileStr = str_replace(['\\', $this->rootDir], ['/', ''], $fileStr);
|
||||
$fileStr = htmlspecialchars($fileStr, $flags, $this->charset);
|
||||
$fileStr = sprintf('<abbr title="%s">kernel.project_dir</abbr>/%s', htmlspecialchars($this->rootDir, $flags, $this->charset), $fileStr);
|
||||
}
|
||||
|
||||
$text = sprintf('%s at line %d', $fileStr, $line);
|
||||
}
|
||||
|
||||
if (false !== $link = $this->getFileLink($file, $line)) {
|
||||
return sprintf('<a href="%s" title="Click to open this file" class="file_link">%s</a>', htmlspecialchars($link, $flags, $this->charset), $text);
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the link for a given file/line pair.
|
||||
*
|
||||
* @param string $file An absolute file path
|
||||
* @param int $line The line number
|
||||
*
|
||||
* @return string A link of false
|
||||
*/
|
||||
public function getFileLink($file, $line)
|
||||
{
|
||||
if ($fmt = $this->fileLinkFormat) {
|
||||
return \is_string($fmt) ? strtr($fmt, ['%f' => $file, '%l' => $line]) : $fmt->format($file, $line);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function formatFileFromText($text)
|
||||
{
|
||||
return preg_replace_callback('/in ("|")?(.+?)\1(?: +(?:on|at))? +line (\d+)/s', function ($match) {
|
||||
return 'in '.$this->formatFile($match[2], $match[3]);
|
||||
}, $text);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'code';
|
||||
}
|
||||
|
||||
protected static function fixCodeMarkup($line)
|
||||
{
|
||||
// </span> ending tag from previous line
|
||||
$opening = strpos($line, '<span');
|
||||
$closing = strpos($line, '</span>');
|
||||
if (false !== $closing && (false === $opening || $closing < $opening)) {
|
||||
$line = substr_replace($line, '', $closing, 7);
|
||||
}
|
||||
|
||||
// missing </span> tag at the end of line
|
||||
$opening = strpos($line, '<span');
|
||||
$closing = strpos($line, '</span>');
|
||||
if (false !== $opening && (false === $closing || $closing > $opening)) {
|
||||
$line .= '</span>';
|
||||
}
|
||||
|
||||
return $line;
|
||||
}
|
||||
}
|
@ -1,271 +0,0 @@
|
||||
<?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\Templating\Helper;
|
||||
|
||||
@trigger_error('The '.FormHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\Form\FormRendererInterface;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\Templating\Helper\Helper;
|
||||
|
||||
/**
|
||||
* FormHelper provides helpers to help display forms.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
|
||||
*/
|
||||
class FormHelper extends Helper
|
||||
{
|
||||
private $renderer;
|
||||
|
||||
public function __construct(FormRendererInterface $renderer)
|
||||
{
|
||||
$this->renderer = $renderer;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'form';
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a theme for a given view.
|
||||
*
|
||||
* The theme format is "<Bundle>:<Controller>".
|
||||
*
|
||||
* @param FormView $view A FormView instance
|
||||
* @param string|array $themes A theme or an array of theme
|
||||
* @param bool $useDefaultThemes If true, will use default themes defined in the renderer
|
||||
*/
|
||||
public function setTheme(FormView $view, $themes, $useDefaultThemes = true)
|
||||
{
|
||||
$this->renderer->setTheme($view, $themes, $useDefaultThemes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the HTML for a form.
|
||||
*
|
||||
* Example usage:
|
||||
*
|
||||
* <?php echo view['form']->form($form) ?>
|
||||
*
|
||||
* You can pass options during the call:
|
||||
*
|
||||
* <?php echo view['form']->form($form, ['attr' => ['class' => 'foo']]) ?>
|
||||
*
|
||||
* <?php echo view['form']->form($form, ['separator' => '+++++']) ?>
|
||||
*
|
||||
* This method is mainly intended for prototyping purposes. If you want to
|
||||
* control the layout of a form in a more fine-grained manner, you are
|
||||
* advised to use the other helper methods for rendering the parts of the
|
||||
* form individually. You can also create a custom form theme to adapt
|
||||
* the look of the form.
|
||||
*
|
||||
* @param FormView $view The view for which to render the form
|
||||
* @param array $variables Additional variables passed to the template
|
||||
*
|
||||
* @return string The HTML markup
|
||||
*/
|
||||
public function form(FormView $view, array $variables = [])
|
||||
{
|
||||
return $this->renderer->renderBlock($view, 'form', $variables);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the form start tag.
|
||||
*
|
||||
* Example usage templates:
|
||||
*
|
||||
* <?php echo $view['form']->start($form) ?>>
|
||||
*
|
||||
* @param FormView $view The view for which to render the start tag
|
||||
* @param array $variables Additional variables passed to the template
|
||||
*
|
||||
* @return string The HTML markup
|
||||
*/
|
||||
public function start(FormView $view, array $variables = [])
|
||||
{
|
||||
return $this->renderer->renderBlock($view, 'form_start', $variables);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the form end tag.
|
||||
*
|
||||
* Example usage templates:
|
||||
*
|
||||
* <?php echo $view['form']->end($form) ?>>
|
||||
*
|
||||
* @param FormView $view The view for which to render the end tag
|
||||
* @param array $variables Additional variables passed to the template
|
||||
*
|
||||
* @return string The HTML markup
|
||||
*/
|
||||
public function end(FormView $view, array $variables = [])
|
||||
{
|
||||
return $this->renderer->renderBlock($view, 'form_end', $variables);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the HTML for a given view.
|
||||
*
|
||||
* Example usage:
|
||||
*
|
||||
* <?php echo $view['form']->widget($form) ?>
|
||||
*
|
||||
* You can pass options during the call:
|
||||
*
|
||||
* <?php echo $view['form']->widget($form, ['attr' => ['class' => 'foo']]) ?>
|
||||
*
|
||||
* <?php echo $view['form']->widget($form, ['separator' => '+++++']) ?>
|
||||
*
|
||||
* @param FormView $view The view for which to render the widget
|
||||
* @param array $variables Additional variables passed to the template
|
||||
*
|
||||
* @return string The HTML markup
|
||||
*/
|
||||
public function widget(FormView $view, array $variables = [])
|
||||
{
|
||||
return $this->renderer->searchAndRenderBlock($view, 'widget', $variables);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the entire form field "row".
|
||||
*
|
||||
* @param FormView $view The view for which to render the row
|
||||
* @param array $variables Additional variables passed to the template
|
||||
*
|
||||
* @return string The HTML markup
|
||||
*/
|
||||
public function row(FormView $view, array $variables = [])
|
||||
{
|
||||
return $this->renderer->searchAndRenderBlock($view, 'row', $variables);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the label of the given view.
|
||||
*
|
||||
* @param FormView $view The view for which to render the label
|
||||
* @param string $label The label
|
||||
* @param array $variables Additional variables passed to the template
|
||||
*
|
||||
* @return string The HTML markup
|
||||
*/
|
||||
public function label(FormView $view, $label = null, array $variables = [])
|
||||
{
|
||||
if (null !== $label) {
|
||||
$variables += ['label' => $label];
|
||||
}
|
||||
|
||||
return $this->renderer->searchAndRenderBlock($view, 'label', $variables);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the help of the given view.
|
||||
*
|
||||
* @param FormView $view The parent view
|
||||
*
|
||||
* @return string The HTML markup
|
||||
*/
|
||||
public function help(FormView $view): string
|
||||
{
|
||||
return $this->renderer->searchAndRenderBlock($view, 'help');
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the errors of the given view.
|
||||
*
|
||||
* @return string The HTML markup
|
||||
*/
|
||||
public function errors(FormView $view)
|
||||
{
|
||||
return $this->renderer->searchAndRenderBlock($view, 'errors');
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders views which have not already been rendered.
|
||||
*
|
||||
* @param FormView $view The parent view
|
||||
* @param array $variables An array of variables
|
||||
*
|
||||
* @return string The HTML markup
|
||||
*/
|
||||
public function rest(FormView $view, array $variables = [])
|
||||
{
|
||||
return $this->renderer->searchAndRenderBlock($view, 'rest', $variables);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a block of the template.
|
||||
*
|
||||
* @param FormView $view The view for determining the used themes
|
||||
* @param string $blockName The name of the block to render
|
||||
* @param array $variables The variable to pass to the template
|
||||
*
|
||||
* @return string The HTML markup
|
||||
*/
|
||||
public function block(FormView $view, $blockName, array $variables = [])
|
||||
{
|
||||
return $this->renderer->renderBlock($view, $blockName, $variables);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a CSRF token.
|
||||
*
|
||||
* Use this helper for CSRF protection without the overhead of creating a
|
||||
* form.
|
||||
*
|
||||
* echo $view['form']->csrfToken('rm_user_'.$user->getId());
|
||||
*
|
||||
* Check the token in your action using the same CSRF token id.
|
||||
*
|
||||
* // $csrfProvider being an instance of Symfony\Component\Security\Csrf\TokenGenerator\TokenGeneratorInterface
|
||||
* if (!$csrfProvider->isCsrfTokenValid('rm_user_'.$user->getId(), $token)) {
|
||||
* throw new \RuntimeException('CSRF attack detected.');
|
||||
* }
|
||||
*
|
||||
* @param string $tokenId The CSRF token id of the protected action
|
||||
*
|
||||
* @return string A CSRF token
|
||||
*
|
||||
* @throws \BadMethodCallException when no CSRF provider was injected in the constructor
|
||||
*/
|
||||
public function csrfToken($tokenId)
|
||||
{
|
||||
return $this->renderer->renderCsrfToken($tokenId);
|
||||
}
|
||||
|
||||
public function humanize($text)
|
||||
{
|
||||
return $this->renderer->humanize($text);
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function formEncodeCurrency($text, $widget = '')
|
||||
{
|
||||
if ('UTF-8' === $charset = $this->getCharset()) {
|
||||
$text = htmlspecialchars($text, ENT_QUOTES | (\defined('ENT_SUBSTITUTE') ? ENT_SUBSTITUTE : 0), 'UTF-8');
|
||||
} else {
|
||||
$text = htmlentities($text, ENT_QUOTES | (\defined('ENT_SUBSTITUTE') ? ENT_SUBSTITUTE : 0), 'UTF-8');
|
||||
$text = iconv('UTF-8', $charset, $text);
|
||||
$widget = iconv('UTF-8', $charset, $widget);
|
||||
}
|
||||
|
||||
return str_replace('{{ widget }}', $widget, $text);
|
||||
}
|
||||
}
|
@ -1,76 +0,0 @@
|
||||
<?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\Templating\Helper;
|
||||
|
||||
@trigger_error('The '.RequestHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\Templating\Helper\Helper;
|
||||
|
||||
/**
|
||||
* RequestHelper provides access to the current request parameters.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
|
||||
*/
|
||||
class RequestHelper extends Helper
|
||||
{
|
||||
protected $requestStack;
|
||||
|
||||
public function __construct(RequestStack $requestStack)
|
||||
{
|
||||
$this->requestStack = $requestStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a parameter from the current request object.
|
||||
*
|
||||
* @param string $key The name of the parameter
|
||||
* @param string $default A default value
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @see Request::get()
|
||||
*/
|
||||
public function getParameter($key, $default = null)
|
||||
{
|
||||
return $this->getRequest()->get($key, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the locale.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLocale()
|
||||
{
|
||||
return $this->getRequest()->getLocale();
|
||||
}
|
||||
|
||||
private function getRequest()
|
||||
{
|
||||
if (!$this->requestStack->getCurrentRequest()) {
|
||||
throw new \LogicException('A Request must be available.');
|
||||
}
|
||||
|
||||
return $this->requestStack->getCurrentRequest();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'request';
|
||||
}
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
<?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\Templating\Helper;
|
||||
|
||||
@trigger_error('The '.RouterHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Templating\Helper\Helper;
|
||||
|
||||
/**
|
||||
* RouterHelper manages links between pages in a template context.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
|
||||
*/
|
||||
class RouterHelper extends Helper
|
||||
{
|
||||
protected $generator;
|
||||
|
||||
public function __construct(UrlGeneratorInterface $router)
|
||||
{
|
||||
$this->generator = $router;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a URL reference (as an absolute or relative path) to the route with the given parameters.
|
||||
*
|
||||
* @param string $name The name of the route
|
||||
* @param mixed $parameters An array of parameters
|
||||
* @param bool $relative Whether to generate a relative or absolute path
|
||||
*
|
||||
* @return string The generated URL reference
|
||||
*
|
||||
* @see UrlGeneratorInterface
|
||||
*/
|
||||
public function path($name, $parameters = [], $relative = false)
|
||||
{
|
||||
return $this->generator->generate($name, $parameters, $relative ? UrlGeneratorInterface::RELATIVE_PATH : UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a URL reference (as an absolute URL or network path) to the route with the given parameters.
|
||||
*
|
||||
* @param string $name The name of the route
|
||||
* @param mixed $parameters An array of parameters
|
||||
* @param bool $schemeRelative Whether to omit the scheme in the generated URL reference
|
||||
*
|
||||
* @return string The generated URL reference
|
||||
*
|
||||
* @see UrlGeneratorInterface
|
||||
*/
|
||||
public function url($name, $parameters = [], $schemeRelative = false)
|
||||
{
|
||||
return $this->generator->generate($name, $parameters, $schemeRelative ? UrlGeneratorInterface::NETWORK_PATH : UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'router';
|
||||
}
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
<?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\Templating\Helper;
|
||||
|
||||
@trigger_error('The '.SessionHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\Templating\Helper\Helper;
|
||||
|
||||
/**
|
||||
* SessionHelper provides read-only access to the session attributes.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
|
||||
*/
|
||||
class SessionHelper extends Helper
|
||||
{
|
||||
protected $session;
|
||||
protected $requestStack;
|
||||
|
||||
public function __construct(RequestStack $requestStack)
|
||||
{
|
||||
$this->requestStack = $requestStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an attribute.
|
||||
*
|
||||
* @param string $name The attribute name
|
||||
* @param mixed $default The default value
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($name, $default = null)
|
||||
{
|
||||
return $this->getSession()->get($name, $default);
|
||||
}
|
||||
|
||||
public function getFlash($name, array $default = [])
|
||||
{
|
||||
return $this->getSession()->getFlashBag()->get($name, $default);
|
||||
}
|
||||
|
||||
public function getFlashes()
|
||||
{
|
||||
return $this->getSession()->getFlashBag()->all();
|
||||
}
|
||||
|
||||
public function hasFlash($name)
|
||||
{
|
||||
return $this->getSession()->getFlashBag()->has($name);
|
||||
}
|
||||
|
||||
private function getSession()
|
||||
{
|
||||
if (null === $this->session) {
|
||||
if (!$this->requestStack->getMasterRequest()) {
|
||||
throw new \LogicException('A Request must be available.');
|
||||
}
|
||||
|
||||
$this->session = $this->requestStack->getMasterRequest()->getSession();
|
||||
}
|
||||
|
||||
return $this->session;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'session';
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
<?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\Templating\Helper;
|
||||
|
||||
@trigger_error('The '.StopwatchHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\Stopwatch\Stopwatch;
|
||||
use Symfony\Component\Templating\Helper\Helper;
|
||||
|
||||
/**
|
||||
* StopwatchHelper provides methods time your PHP templates.
|
||||
*
|
||||
* @author Wouter J <wouter@wouterj.nl>
|
||||
*
|
||||
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
|
||||
*/
|
||||
class StopwatchHelper extends Helper
|
||||
{
|
||||
private $stopwatch;
|
||||
|
||||
public function __construct(Stopwatch $stopwatch = null)
|
||||
{
|
||||
$this->stopwatch = $stopwatch;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return 'stopwatch';
|
||||
}
|
||||
|
||||
public function __call($method, $arguments = [])
|
||||
{
|
||||
if (null !== $this->stopwatch) {
|
||||
if (method_exists($this->stopwatch, $method)) {
|
||||
return $this->stopwatch->{$method}(...$arguments);
|
||||
}
|
||||
|
||||
throw new \BadMethodCallException(sprintf('Method "%s" of Stopwatch does not exist', $method));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
<?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\Templating\Helper;
|
||||
|
||||
@trigger_error('The '.TranslatorHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\Templating\Helper\Helper;
|
||||
use Symfony\Component\Translation\TranslatorInterface as LegacyTranslatorInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorTrait;
|
||||
|
||||
/**
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
|
||||
*/
|
||||
class TranslatorHelper extends Helper
|
||||
{
|
||||
use TranslatorTrait {
|
||||
getLocale as private;
|
||||
setLocale as private;
|
||||
trans as private doTrans;
|
||||
}
|
||||
|
||||
protected $translator;
|
||||
|
||||
/**
|
||||
* @param TranslatorInterface|null $translator
|
||||
*/
|
||||
public function __construct($translator = null)
|
||||
{
|
||||
if (null !== $translator && !$translator instanceof LegacyTranslatorInterface && !$translator instanceof TranslatorInterface) {
|
||||
throw new \TypeError(sprintf('Argument 1 passed to %s() must be an instance of %s, %s given.', __METHOD__, TranslatorInterface::class, \is_object($translator) ? \get_class($translator) : \gettype($translator)));
|
||||
}
|
||||
$this->translator = $translator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see TranslatorInterface::trans()
|
||||
*/
|
||||
public function trans($id, array $parameters = [], $domain = 'messages', $locale = null)
|
||||
{
|
||||
if (null === $this->translator) {
|
||||
return $this->doTrans($id, $parameters, $domain, $locale);
|
||||
}
|
||||
|
||||
return $this->translator->trans($id, $parameters, $domain, $locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see TranslatorInterface::transChoice()
|
||||
* @deprecated since Symfony 4.2, use the trans() method instead with a %count% parameter
|
||||
*/
|
||||
public function transChoice($id, $number, array $parameters = [], $domain = 'messages', $locale = null)
|
||||
{
|
||||
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the trans() one instead with a "%%count%%" parameter.', __METHOD__), E_USER_DEPRECATED);
|
||||
|
||||
if (null === $this->translator) {
|
||||
return $this->doTrans($id, ['%count%' => $number] + $parameters, $domain, $locale);
|
||||
}
|
||||
if ($this->translator instanceof TranslatorInterface) {
|
||||
return $this->translator->trans($id, ['%count%' => $number] + $parameters, $domain, $locale);
|
||||
}
|
||||
|
||||
return $this->translator->transChoice($id, $number, $parameters, $domain, $locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'translator';
|
||||
}
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
<?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\Templating\Loader;
|
||||
|
||||
@trigger_error('The '.FilesystemLoader::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\Config\FileLocatorInterface;
|
||||
use Symfony\Component\Templating\Loader\LoaderInterface;
|
||||
use Symfony\Component\Templating\Storage\FileStorage;
|
||||
use Symfony\Component\Templating\TemplateReferenceInterface;
|
||||
|
||||
/**
|
||||
* FilesystemLoader is a loader that read templates from the filesystem.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
|
||||
*/
|
||||
class FilesystemLoader implements LoaderInterface
|
||||
{
|
||||
protected $locator;
|
||||
|
||||
public function __construct(FileLocatorInterface $locator)
|
||||
{
|
||||
$this->locator = $locator;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function load(TemplateReferenceInterface $template)
|
||||
{
|
||||
try {
|
||||
$file = $this->locator->locate($template);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return new FileStorage($file);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isFresh(TemplateReferenceInterface $template, $time)
|
||||
{
|
||||
if (false === $storage = $this->load($template)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!is_readable((string) $storage)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return filemtime((string) $storage) < $time;
|
||||
}
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
<?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\Templating\Loader;
|
||||
|
||||
@trigger_error('The '.TemplateLocator::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\Config\FileLocatorInterface;
|
||||
use Symfony\Component\Templating\TemplateReferenceInterface;
|
||||
|
||||
/**
|
||||
* TemplateLocator locates templates in bundles.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
|
||||
*/
|
||||
class TemplateLocator implements FileLocatorInterface
|
||||
{
|
||||
protected $locator;
|
||||
protected $cache;
|
||||
|
||||
private $cacheHits = [];
|
||||
|
||||
/**
|
||||
* @param FileLocatorInterface $locator A FileLocatorInterface instance
|
||||
* @param string $cacheDir The cache path
|
||||
*/
|
||||
public function __construct(FileLocatorInterface $locator, string $cacheDir = null)
|
||||
{
|
||||
if (null !== $cacheDir && file_exists($cache = $cacheDir.'/templates.php')) {
|
||||
$this->cache = require $cache;
|
||||
}
|
||||
|
||||
$this->locator = $locator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a full path for a given file.
|
||||
*
|
||||
* @return string The full path for the file
|
||||
*/
|
||||
protected function getCacheKey($template)
|
||||
{
|
||||
return $template->getLogicalName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a full path for a given file.
|
||||
*
|
||||
* @param TemplateReferenceInterface $template A template
|
||||
* @param string $currentPath Unused
|
||||
* @param bool $first Unused
|
||||
*
|
||||
* @return string The full path for the file
|
||||
*
|
||||
* @throws \InvalidArgumentException When the template is not an instance of TemplateReferenceInterface
|
||||
* @throws \InvalidArgumentException When the template file can not be found
|
||||
*/
|
||||
public function locate($template, $currentPath = null, $first = true)
|
||||
{
|
||||
if (!$template instanceof TemplateReferenceInterface) {
|
||||
throw new \InvalidArgumentException('The template must be an instance of TemplateReferenceInterface.');
|
||||
}
|
||||
|
||||
$key = $this->getCacheKey($template);
|
||||
|
||||
if (isset($this->cacheHits[$key])) {
|
||||
return $this->cacheHits[$key];
|
||||
}
|
||||
if (isset($this->cache[$key])) {
|
||||
return $this->cacheHits[$key] = realpath($this->cache[$key]) ?: $this->cache[$key];
|
||||
}
|
||||
|
||||
try {
|
||||
return $this->cacheHits[$key] = $this->locator->locate($template->getPath(), $currentPath);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
throw new \InvalidArgumentException(sprintf('Unable to find template "%s" : "%s".', $template, $e->getMessage()), 0, $e);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,82 +0,0 @@
|
||||
<?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\Templating;
|
||||
|
||||
@trigger_error('The '.PhpEngine::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);
|
||||
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Templating\Loader\LoaderInterface;
|
||||
use Symfony\Component\Templating\PhpEngine as BasePhpEngine;
|
||||
use Symfony\Component\Templating\TemplateNameParserInterface;
|
||||
|
||||
/**
|
||||
* This engine knows how to render Symfony templates.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
|
||||
*/
|
||||
class PhpEngine extends BasePhpEngine implements EngineInterface
|
||||
{
|
||||
protected $container;
|
||||
|
||||
public function __construct(TemplateNameParserInterface $parser, ContainerInterface $container, LoaderInterface $loader, GlobalVariables $globals = null)
|
||||
{
|
||||
$this->container = $container;
|
||||
|
||||
parent::__construct($parser, $loader);
|
||||
|
||||
if (null !== $globals) {
|
||||
$this->addGlobal('app', $globals);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get($name)
|
||||
{
|
||||
if (!isset($this->helpers[$name])) {
|
||||
throw new \InvalidArgumentException(sprintf('The helper "%s" is not defined.', $name));
|
||||
}
|
||||
|
||||
if (\is_string($this->helpers[$name])) {
|
||||
$this->helpers[$name] = $this->container->get($this->helpers[$name]);
|
||||
$this->helpers[$name]->setCharset($this->charset);
|
||||
}
|
||||
|
||||
return $this->helpers[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setHelpers(array $helpers)
|
||||
{
|
||||
$this->helpers = $helpers;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function renderResponse($view, array $parameters = [], Response $response = null)
|
||||
{
|
||||
if (null === $response) {
|
||||
$response = new Response();
|
||||
}
|
||||
|
||||
$response->setContent($this->render($view, $parameters));
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
<?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\Templating;
|
||||
|
||||
@trigger_error('The '.TemplateFilenameParser::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\Templating\TemplateNameParserInterface;
|
||||
use Symfony\Component\Templating\TemplateReferenceInterface;
|
||||
|
||||
/**
|
||||
* TemplateFilenameParser converts template filenames to
|
||||
* TemplateReferenceInterface instances.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
|
||||
*/
|
||||
class TemplateFilenameParser implements TemplateNameParserInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function parse($name)
|
||||
{
|
||||
if ($name instanceof TemplateReferenceInterface) {
|
||||
return $name;
|
||||
}
|
||||
|
||||
$parts = explode('/', str_replace('\\', '/', $name));
|
||||
|
||||
$elements = explode('.', array_pop($parts));
|
||||
if (3 > \count($elements)) {
|
||||
return false;
|
||||
}
|
||||
$engine = array_pop($elements);
|
||||
$format = array_pop($elements);
|
||||
|
||||
return new TemplateReference('', implode('/', $parts), implode('.', $elements), $format, $engine);
|
||||
}
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
<?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\Templating;
|
||||
|
||||
@trigger_error('The '.TemplateNameParser::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
use Symfony\Component\Templating\TemplateNameParser as BaseTemplateNameParser;
|
||||
use Symfony\Component\Templating\TemplateReferenceInterface;
|
||||
|
||||
/**
|
||||
* TemplateNameParser converts template names from the short notation
|
||||
* "bundle:section:template.format.engine" to TemplateReferenceInterface
|
||||
* instances.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
|
||||
*/
|
||||
class TemplateNameParser extends BaseTemplateNameParser
|
||||
{
|
||||
protected $kernel;
|
||||
protected $cache = [];
|
||||
|
||||
public function __construct(KernelInterface $kernel)
|
||||
{
|
||||
$this->kernel = $kernel;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function parse($name)
|
||||
{
|
||||
if ($name instanceof TemplateReferenceInterface) {
|
||||
return $name;
|
||||
} elseif (isset($this->cache[$name])) {
|
||||
return $this->cache[$name];
|
||||
}
|
||||
|
||||
// normalize name
|
||||
$name = str_replace(':/', ':', preg_replace('#/{2,}#', '/', str_replace('\\', '/', $name)));
|
||||
|
||||
if (false !== strpos($name, '..')) {
|
||||
throw new \RuntimeException(sprintf('Template name "%s" contains invalid characters.', $name));
|
||||
}
|
||||
|
||||
if (!preg_match('/^(?:([^:]*):([^:]*):)?(.+)\.([^\.]+)\.([^\.]+)$/', $name, $matches) || 0 === strpos($name, '@')) {
|
||||
return parent::parse($name);
|
||||
}
|
||||
|
||||
$template = new TemplateReference($matches[1], $matches[2], $matches[3], $matches[4], $matches[5]);
|
||||
|
||||
if ($template->get('bundle')) {
|
||||
try {
|
||||
$this->kernel->getBundle($template->get('bundle'));
|
||||
} catch (\Exception $e) {
|
||||
throw new \InvalidArgumentException(sprintf('Template name "%s" is not valid.', $name), 0, $e);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->cache[$name] = $template;
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
<?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\Templating;
|
||||
|
||||
@trigger_error('The '.TemplateReference::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\Templating\TemplateReference as BaseTemplateReference;
|
||||
|
||||
/**
|
||||
* Internal representation of a template.
|
||||
*
|
||||
* @author Victor Berchet <victor@suumit.com>
|
||||
*
|
||||
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
|
||||
*/
|
||||
class TemplateReference extends BaseTemplateReference
|
||||
{
|
||||
public function __construct(string $bundle = null, string $controller = null, string $name = null, string $format = null, string $engine = null)
|
||||
{
|
||||
$this->parameters = [
|
||||
'bundle' => $bundle,
|
||||
'controller' => $controller,
|
||||
'name' => $name,
|
||||
'format' => $format,
|
||||
'engine' => $engine,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the path to the template
|
||||
* - as a path when the template is not part of a bundle
|
||||
* - as a resource when the template is part of a bundle.
|
||||
*
|
||||
* @return string A path to the template or a resource
|
||||
*/
|
||||
public function getPath()
|
||||
{
|
||||
$controller = str_replace('\\', '/', $this->get('controller'));
|
||||
|
||||
$path = (empty($controller) ? '' : $controller.'/').$this->get('name').'.'.$this->get('format').'.'.$this->get('engine');
|
||||
|
||||
return empty($this->parameters['bundle']) ? 'views/'.$path : '@'.$this->get('bundle').'/Resources/views/'.$path;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getLogicalName()
|
||||
{
|
||||
return sprintf('%s:%s:%s.%s.%s', $this->parameters['bundle'], $this->parameters['controller'], $this->parameters['name'], $this->parameters['format'], $this->parameters['engine']);
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
<?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\Templating;
|
||||
|
||||
@trigger_error('The '.TimedPhpEngine::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);
|
||||
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Symfony\Component\Stopwatch\Stopwatch;
|
||||
use Symfony\Component\Templating\Loader\LoaderInterface;
|
||||
use Symfony\Component\Templating\TemplateNameParserInterface;
|
||||
|
||||
/**
|
||||
* Times the time spent to render a template.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
|
||||
*/
|
||||
class TimedPhpEngine extends PhpEngine
|
||||
{
|
||||
protected $stopwatch;
|
||||
|
||||
public function __construct(TemplateNameParserInterface $parser, ContainerInterface $container, LoaderInterface $loader, Stopwatch $stopwatch, GlobalVariables $globals = null)
|
||||
{
|
||||
parent::__construct($parser, $container, $loader, $globals);
|
||||
|
||||
$this->stopwatch = $stopwatch;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function render($name, array $parameters = [])
|
||||
{
|
||||
$e = $this->stopwatch->start(sprintf('template.php (%s)', $name), 'template');
|
||||
|
||||
$ret = parent::render($name, $parameters);
|
||||
|
||||
$e->stop();
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
<?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\CacheWarmer;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplateFinder;
|
||||
use Symfony\Bundle\FrameworkBundle\Templating\TemplateFilenameParser;
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\BaseBundle\BaseBundle;
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
class TemplateFinderTest extends TestCase
|
||||
{
|
||||
public function testFindAllTemplates()
|
||||
{
|
||||
$kernel = $this
|
||||
->getMockBuilder('Symfony\Component\HttpKernel\Kernel')
|
||||
->disableOriginalConstructor()
|
||||
->getMock()
|
||||
;
|
||||
|
||||
$kernel
|
||||
->expects($this->any())
|
||||
->method('getBundle')
|
||||
;
|
||||
|
||||
$kernel
|
||||
->expects($this->once())
|
||||
->method('getBundles')
|
||||
->willReturn(['BaseBundle' => new BaseBundle()])
|
||||
;
|
||||
|
||||
$parser = new TemplateFilenameParser();
|
||||
|
||||
$finder = new TemplateFinder($kernel, $parser, __DIR__.'/../Fixtures/Resources');
|
||||
|
||||
$templates = array_map(
|
||||
function ($template) { return $template->getLogicalName(); },
|
||||
$finder->findAllTemplates()
|
||||
);
|
||||
|
||||
$this->assertCount(7, $templates, '->findAllTemplates() find all templates in the bundles and global folders');
|
||||
$this->assertContains('BaseBundle::base.format.engine', $templates);
|
||||
$this->assertContains('BaseBundle::this.is.a.template.format.engine', $templates);
|
||||
$this->assertContains('BaseBundle:controller:base.format.engine', $templates);
|
||||
$this->assertContains('BaseBundle:controller:custom.format.engine', $templates);
|
||||
$this->assertContains('::this.is.a.template.format.engine', $templates);
|
||||
$this->assertContains('::resource.format.engine', $templates);
|
||||
}
|
||||
}
|
@ -1,105 +0,0 @@
|
||||
<?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\CacheWarmer;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplateFinderInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplatePathsCacheWarmer;
|
||||
use Symfony\Bundle\FrameworkBundle\Templating\Loader\TemplateLocator;
|
||||
use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference;
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
class TemplatePathsCacheWarmerTest extends TestCase
|
||||
{
|
||||
/** @var Filesystem */
|
||||
private $filesystem;
|
||||
|
||||
/** @var TemplateFinderInterface */
|
||||
private $templateFinder;
|
||||
|
||||
/** @var FileLocator */
|
||||
private $fileLocator;
|
||||
|
||||
/** @var TemplateLocator */
|
||||
private $templateLocator;
|
||||
|
||||
private $tmpDir;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->templateFinder = $this
|
||||
->getMockBuilder(TemplateFinderInterface::class)
|
||||
->setMethods(['findAllTemplates'])
|
||||
->getMock();
|
||||
|
||||
$this->fileLocator = $this
|
||||
->getMockBuilder(FileLocator::class)
|
||||
->setMethods(['locate'])
|
||||
->setConstructorArgs(['/path/to/fallback'])
|
||||
->getMock();
|
||||
|
||||
$this->templateLocator = new TemplateLocator($this->fileLocator);
|
||||
|
||||
$this->tmpDir = sys_get_temp_dir().\DIRECTORY_SEPARATOR.uniqid('cache_template_paths_', true);
|
||||
|
||||
$this->filesystem = new Filesystem();
|
||||
$this->filesystem->mkdir($this->tmpDir);
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
$this->filesystem->remove($this->tmpDir);
|
||||
}
|
||||
|
||||
public function testWarmUp()
|
||||
{
|
||||
$template = new TemplateReference('bundle', 'controller', 'name', 'format', 'engine');
|
||||
|
||||
$this->templateFinder
|
||||
->expects($this->once())
|
||||
->method('findAllTemplates')
|
||||
->willReturn([$template]);
|
||||
|
||||
$this->fileLocator
|
||||
->expects($this->once())
|
||||
->method('locate')
|
||||
->with($template->getPath())
|
||||
->willReturn(\dirname($this->tmpDir).'/path/to/template.html.twig');
|
||||
|
||||
$warmer = new TemplatePathsCacheWarmer($this->templateFinder, $this->templateLocator);
|
||||
$warmer->warmUp($this->tmpDir);
|
||||
|
||||
$this->assertFileEquals(__DIR__.'/../Fixtures/TemplatePathsCache/templates.php', $this->tmpDir.'/templates.php');
|
||||
}
|
||||
|
||||
public function testWarmUpEmpty()
|
||||
{
|
||||
$this->templateFinder
|
||||
->expects($this->once())
|
||||
->method('findAllTemplates')
|
||||
->willReturn([]);
|
||||
|
||||
$this->fileLocator
|
||||
->expects($this->never())
|
||||
->method('locate');
|
||||
|
||||
$warmer = new TemplatePathsCacheWarmer($this->templateFinder, $this->templateLocator);
|
||||
$warmer->warmUp($this->tmpDir);
|
||||
|
||||
$this->assertFileExists($this->tmpDir.'/templates.php');
|
||||
$this->assertSame(file_get_contents(__DIR__.'/../Fixtures/TemplatePathsCache/templates-empty.php'), file_get_contents($this->tmpDir.'/templates.php'));
|
||||
}
|
||||
}
|
@ -37,7 +37,6 @@ class AbstractControllerTest extends ControllerTraitTest
|
||||
'serializer' => '?Symfony\\Component\\Serializer\\SerializerInterface',
|
||||
'session' => '?Symfony\\Component\\HttpFoundation\\Session\\SessionInterface',
|
||||
'security.authorization_checker' => '?Symfony\\Component\\Security\\Core\\Authorization\\AuthorizationCheckerInterface',
|
||||
'templating' => '?Symfony\\Component\\Templating\\EngineInterface',
|
||||
'twig' => '?Twig\\Environment',
|
||||
'doctrine' => '?Doctrine\\Common\\Persistence\\ManagerRegistry',
|
||||
'form.factory' => '?Symfony\\Component\\Form\\FormFactoryInterface',
|
||||
|
@ -439,56 +439,6 @@ abstract class ControllerTraitTest extends TestCase
|
||||
$this->assertSame(301, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testRenderViewTemplating()
|
||||
{
|
||||
$templating = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface')->getMock();
|
||||
$templating->expects($this->once())->method('render')->willReturn('bar');
|
||||
|
||||
$container = new Container();
|
||||
$container->set('templating', $templating);
|
||||
|
||||
$controller = $this->createController();
|
||||
$controller->setContainer($container);
|
||||
|
||||
$this->assertEquals('bar', $controller->renderView('foo'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testRenderTemplating()
|
||||
{
|
||||
$templating = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface')->getMock();
|
||||
$templating->expects($this->once())->method('render')->willReturn('bar');
|
||||
|
||||
$container = new Container();
|
||||
$container->set('templating', $templating);
|
||||
|
||||
$controller = $this->createController();
|
||||
$controller->setContainer($container);
|
||||
|
||||
$this->assertEquals('bar', $controller->render('foo')->getContent());
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testStreamTemplating()
|
||||
{
|
||||
$templating = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface')->getMock();
|
||||
|
||||
$container = new Container();
|
||||
$container->set('templating', $templating);
|
||||
|
||||
$controller = $this->createController();
|
||||
$controller->setContainer($container);
|
||||
|
||||
$this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $controller->stream('foo'));
|
||||
}
|
||||
|
||||
public function testCreateNotFoundException()
|
||||
{
|
||||
$controller = $this->createController();
|
||||
|
@ -12,7 +12,6 @@
|
||||
namespace Symfony\Bundle\FrameworkBundle\Tests\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\TemplateController;
|
||||
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
||||
|
||||
/**
|
||||
@ -31,25 +30,11 @@ class TemplateControllerTest extends TestCase
|
||||
$this->assertEquals('bar', $controller('mytemplate')->getContent());
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testTemplating()
|
||||
{
|
||||
$templating = $this->getMockBuilder(EngineInterface::class)->getMock();
|
||||
$templating->expects($this->exactly(2))->method('render')->willReturn('bar');
|
||||
|
||||
$controller = new TemplateController(null, $templating);
|
||||
|
||||
$this->assertEquals('bar', $controller->templateAction('mytemplate')->getContent());
|
||||
$this->assertEquals('bar', $controller('mytemplate')->getContent());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage You can not use the TemplateController if the Templating Component or the Twig Bundle are not available.
|
||||
* @expectedExceptionMessage You can not use the TemplateController if the Twig Bundle is not available.
|
||||
*/
|
||||
public function testNoTwigNorTemplating()
|
||||
public function testNoTwig()
|
||||
{
|
||||
$controller = new TemplateController();
|
||||
|
||||
|
@ -35,19 +35,6 @@ class ConfigurationTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function testDoNoDuplicateDefaultFormResources()
|
||||
{
|
||||
$input = ['templating' => [
|
||||
'form' => ['resources' => ['FrameworkBundle:Form']],
|
||||
'engines' => ['php'],
|
||||
]];
|
||||
|
||||
$processor = new Processor();
|
||||
$config = $processor->processConfiguration(new Configuration(true), [$input]);
|
||||
|
||||
$this->assertEquals(['FrameworkBundle:Form'], $config['templating']['form']['resources']);
|
||||
}
|
||||
|
||||
public function getTestValidSessionName()
|
||||
{
|
||||
return [
|
||||
@ -305,15 +292,6 @@ class ConfigurationTest extends TestCase
|
||||
'enabled' => false,
|
||||
'formats' => [],
|
||||
],
|
||||
'templating' => [
|
||||
'enabled' => false,
|
||||
'hinclude_default_template' => null,
|
||||
'form' => [
|
||||
'resources' => ['FrameworkBundle:Form'],
|
||||
],
|
||||
'engines' => [],
|
||||
'loaders' => [],
|
||||
],
|
||||
'assets' => [
|
||||
'enabled' => !class_exists(FullStack::class),
|
||||
'version_strategy' => null,
|
||||
|
@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'templating' => [
|
||||
'cache' => '/path/to/cache',
|
||||
'engines' => ['php', 'twig'],
|
||||
'loader' => ['loader.foo', 'loader.bar'],
|
||||
'form' => [
|
||||
'resources' => ['theme1', 'theme2'],
|
||||
],
|
||||
'hinclude_default_template' => 'global_hinclude_template',
|
||||
],
|
||||
'assets' => null,
|
||||
'fragments' => [
|
||||
'enabled' => true,
|
||||
'hinclude_default_template' => 'global_hinclude_template',
|
||||
],
|
||||
]);
|
@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'templating' => [
|
||||
'cache' => '/path/to/cache',
|
||||
'engines' => ['php', 'twig'],
|
||||
'loader' => ['loader.foo', 'loader.bar'],
|
||||
'form' => [
|
||||
'resources' => ['theme1', 'theme2'],
|
||||
],
|
||||
'hinclude_default_template' => 'global_hinclude_template',
|
||||
],
|
||||
'assets' => null,
|
||||
]);
|
@ -1,5 +0,0 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'templating' => false,
|
||||
]);
|
@ -1,7 +0,0 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'templating' => [
|
||||
'engines' => ['php', 'twig'],
|
||||
],
|
||||
]);
|
@ -1,8 +0,0 @@
|
||||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'assets' => false,
|
||||
'templating' => [
|
||||
'engines' => ['php'],
|
||||
],
|
||||
]);
|
@ -1,24 +0,0 @@
|
||||
<?xml version="1.0" ?>
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:framework="http://symfony.com/schema/dic/symfony"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
|
||||
|
||||
<framework:config>
|
||||
<framework:fragments enabled="true" hinclude-default-template="global_hinclude_template"/>
|
||||
<framework:esi enabled="true" />
|
||||
<framework:ssi enabled="true" />
|
||||
<framework:assets />
|
||||
<framework:templating cache="/path/to/cache" hinclude-default-template="global_hinclude_template">
|
||||
<framework:loader>loader.foo</framework:loader>
|
||||
<framework:loader>loader.bar</framework:loader>
|
||||
<framework:engine>php</framework:engine>
|
||||
<framework:engine>twig</framework:engine>
|
||||
<framework:form>
|
||||
<framework:resource>theme1</framework:resource>
|
||||
<framework:resource>theme2</framework:resource>
|
||||
</framework:form>
|
||||
</framework:templating>
|
||||
</framework:config>
|
||||
</container>
|
@ -1,22 +0,0 @@
|
||||
<?xml version="1.0" ?>
|
||||
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:framework="http://symfony.com/schema/dic/symfony"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
|
||||
|
||||
<framework:config secret="s3cr3t">
|
||||
<framework:assets />
|
||||
<framework:templating cache="/path/to/cache" hinclude-default-template="global_hinclude_template">
|
||||
<framework:loader>loader.foo</framework:loader>
|
||||
<framework:loader>loader.bar</framework:loader>
|
||||
<framework:engine>php</framework:engine>
|
||||
<framework:engine>twig</framework:engine>
|
||||
<framework:form>
|
||||
<framework:resource>theme1</framework:resource>
|
||||
<framework:resource>theme2</framework:resource>
|
||||
</framework:form>
|
||||
</framework:templating>
|
||||
</framework:config>
|
||||
</container>
|
@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" ?>
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:framework="http://symfony.com/schema/dic/symfony"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
|
||||
|
||||
<framework:config>
|
||||
<framework:templating enabled="false" />
|
||||
</framework:config>
|
||||
</container>
|
@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" ?>
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:framework="http://symfony.com/schema/dic/symfony"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
|
||||
|
||||
<framework:config>
|
||||
<framework:templating>
|
||||
<framework:engine>php</framework:engine>
|
||||
<framework:engine>twig</framework:engine>
|
||||
</framework:templating>
|
||||
</framework:config>
|
||||
</container>
|
@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" ?>
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:framework="http://symfony.com/schema/dic/symfony"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
|
||||
|
||||
<framework:config>
|
||||
<framework:translator enabled="false" />
|
||||
<framework:templating>
|
||||
<framework:engine>php</framework:engine>
|
||||
</framework:templating>
|
||||
</framework:config>
|
||||
</container>
|
@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" ?>
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:framework="http://symfony.com/schema/dic/symfony"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
|
||||
|
||||
<framework:config>
|
||||
<framework:translator enabled="true" />
|
||||
<framework:templating>
|
||||
<framework:engine>php</framework:engine>
|
||||
</framework:templating>
|
||||
</framework:config>
|
||||
</container>
|
@ -1,12 +0,0 @@
|
||||
framework:
|
||||
fragments:
|
||||
enabled: true
|
||||
hinclude_default_template: global_hinclude_template
|
||||
templating:
|
||||
engines: [php, twig]
|
||||
loader: [loader.foo, loader.bar]
|
||||
cache: /path/to/cache
|
||||
form:
|
||||
resources: [theme1, theme2]
|
||||
hinclude_default_template: global_hinclude_template
|
||||
assets: ~
|
@ -1,9 +0,0 @@
|
||||
framework:
|
||||
templating:
|
||||
engines: [php, twig]
|
||||
loader: [loader.foo, loader.bar]
|
||||
cache: /path/to/cache
|
||||
form:
|
||||
resources: [theme1, theme2]
|
||||
hinclude_default_template: global_hinclude_template
|
||||
assets: ~
|
@ -1,2 +0,0 @@
|
||||
framework:
|
||||
templating: false
|
@ -1,3 +0,0 @@
|
||||
framework:
|
||||
templating:
|
||||
engines: [php, twig]
|
@ -1,4 +0,0 @@
|
||||
framework:
|
||||
assets: false
|
||||
templating:
|
||||
engines: [php]
|
@ -1,4 +0,0 @@
|
||||
framework:
|
||||
translator: false
|
||||
templating:
|
||||
engines: [php]
|
@ -1,4 +0,0 @@
|
||||
framework:
|
||||
translator: true
|
||||
templating:
|
||||
engines: [php]
|
@ -160,15 +160,6 @@ abstract class FrameworkExtensionTest extends TestCase
|
||||
$this->assertFalse($container->hasDefinition('esi'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedException \LogicException
|
||||
*/
|
||||
public function testAmbiguousWhenBothTemplatingAndFragments()
|
||||
{
|
||||
$this->createContainerFromFile('template_and_fragments');
|
||||
}
|
||||
|
||||
public function testSsi()
|
||||
{
|
||||
$container = $this->createContainerFromFile('full');
|
||||
@ -575,37 +566,6 @@ abstract class FrameworkExtensionTest extends TestCase
|
||||
$this->assertFalse($container->hasDefinition('request.add_request_formats_listener'), '->registerRequestConfiguration() does not load request.xml when no request formats are defined');
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testTemplating()
|
||||
{
|
||||
$container = $this->createContainerFromFile('templating');
|
||||
|
||||
$this->assertTrue($container->hasDefinition('templating.name_parser'), '->registerTemplatingConfiguration() loads templating.xml');
|
||||
|
||||
$this->assertEquals('templating.engine.delegating', (string) $container->getAlias('templating'), '->registerTemplatingConfiguration() configures delegating loader if multiple engines are provided');
|
||||
|
||||
$this->assertEquals($container->getDefinition('templating.loader.chain'), $container->getDefinition('templating.loader.wrapped'), '->registerTemplatingConfiguration() configures loader chain if multiple loaders are provided');
|
||||
|
||||
$this->assertEquals($container->getDefinition('templating.loader'), $container->getDefinition('templating.loader.cache'), '->registerTemplatingConfiguration() configures the loader to use cache');
|
||||
|
||||
$this->assertEquals('%templating.loader.cache.path%', $container->getDefinition('templating.loader.cache')->getArgument(1));
|
||||
$this->assertEquals('/path/to/cache', $container->getParameter('templating.loader.cache.path'));
|
||||
|
||||
$this->assertEquals(['php', 'twig'], $container->getParameter('templating.engines'), '->registerTemplatingConfiguration() sets a templating.engines parameter');
|
||||
|
||||
$this->assertEquals(['FrameworkBundle:Form', 'theme1', 'theme2'], $container->getParameter('templating.helper.form.resources'), '->registerTemplatingConfiguration() registers the theme and adds the base theme');
|
||||
$this->assertEquals('global_hinclude_template', $container->getParameter('fragment.renderer.hinclude.global_template'), '->registerTemplatingConfiguration() registers the global hinclude.js template');
|
||||
}
|
||||
|
||||
public function testTemplatingCanBeDisabled()
|
||||
{
|
||||
$container = $this->createContainerFromFile('templating_disabled');
|
||||
|
||||
$this->assertFalse($container->hasParameter('templating.engines'), '"templating.engines" container parameter is not registered when templating is disabled.');
|
||||
}
|
||||
|
||||
public function testAssets()
|
||||
{
|
||||
$container = $this->createContainerFromFile('assets');
|
||||
@ -650,13 +610,6 @@ abstract class FrameworkExtensionTest extends TestCase
|
||||
$this->assertEquals('assets.custom_version_strategy', (string) $defaultPackage->getArgument(1));
|
||||
}
|
||||
|
||||
public function testAssetsCanBeDisabled()
|
||||
{
|
||||
$container = $this->createContainerFromFile('assets_disabled');
|
||||
|
||||
$this->assertFalse($container->has('templating.helper.assets'), 'The templating.helper.assets helper service is removed when assets are disabled.');
|
||||
}
|
||||
|
||||
public function testWebLink()
|
||||
{
|
||||
$container = $this->createContainerFromFile('web_link');
|
||||
@ -849,16 +802,6 @@ abstract class FrameworkExtensionTest extends TestCase
|
||||
$this->assertEquals(['en', 'fr'], $calls[1][1][0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
|
||||
*/
|
||||
public function testTemplatingRequiresAtLeastOneEngine()
|
||||
{
|
||||
$container = $this->createContainer();
|
||||
$loader = new FrameworkExtension();
|
||||
$loader->load([['templating' => null]], $container);
|
||||
}
|
||||
|
||||
public function testValidation()
|
||||
{
|
||||
$container = $this->createContainerFromFile('full');
|
||||
@ -1283,45 +1226,6 @@ abstract class FrameworkExtensionTest extends TestCase
|
||||
$this->assertEquals($expectedLoaders, $loaders);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testAssetHelperWhenAssetsAreEnabled()
|
||||
{
|
||||
$container = $this->createContainerFromFile('templating');
|
||||
$packages = $container->getDefinition('templating.helper.assets')->getArgument(0);
|
||||
|
||||
$this->assertSame('assets.packages', (string) $packages);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testAssetHelperWhenTemplatesAreEnabledAndNoAssetsConfiguration()
|
||||
{
|
||||
$container = $this->createContainerFromFile('templating_no_assets');
|
||||
$packages = $container->getDefinition('templating.helper.assets')->getArgument(0);
|
||||
|
||||
$this->assertSame('assets.packages', (string) $packages);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testAssetsHelperIsRemovedWhenPhpTemplatingEngineIsEnabledAndAssetsAreDisabled()
|
||||
{
|
||||
$container = $this->createContainerFromFile('templating_php_assets_disabled');
|
||||
|
||||
$this->assertTrue(!$container->has('templating.helper.assets'), 'The templating.helper.assets helper service is removed when assets are disabled.');
|
||||
}
|
||||
|
||||
public function testAssetHelperWhenAssetsAndTemplatesAreDisabled()
|
||||
{
|
||||
$container = $this->createContainerFromFile('default_config');
|
||||
|
||||
$this->assertFalse($container->hasDefinition('templating.helper.assets'));
|
||||
}
|
||||
|
||||
public function testSerializerServiceIsRegisteredWhenEnabled()
|
||||
{
|
||||
$container = $this->createContainerFromFile('serializer_enabled');
|
||||
|
@ -13,11 +13,9 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
|
||||
|
||||
use Doctrine\Common\Annotations\AnnotationReader;
|
||||
use Doctrine\Common\Annotations\CachedReader;
|
||||
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface as FrameworkBundleEngineInterface;
|
||||
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||
use Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher;
|
||||
use Symfony\Component\Templating\EngineInterface as ComponentEngineInterface;
|
||||
|
||||
class AutowiringTypesTest extends WebTestCase
|
||||
{
|
||||
@ -37,18 +35,6 @@ class AutowiringTypesTest extends WebTestCase
|
||||
$this->assertInstanceOf(CachedReader::class, $annotationReader);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testTemplatingAutowiring()
|
||||
{
|
||||
static::bootKernel(['root_config' => 'templating.yml', 'environment' => 'templating']);
|
||||
|
||||
$autowiredServices = static::$container->get('test.autowiring_types.autowired_services');
|
||||
$this->assertInstanceOf(FrameworkBundleEngineInterface::class, $autowiredServices->getFrameworkBundleEngine());
|
||||
$this->assertInstanceOf(ComponentEngineInterface::class, $autowiredServices->getEngine());
|
||||
}
|
||||
|
||||
public function testEventDispatcherAutowiring()
|
||||
{
|
||||
static::bootKernel(['debug' => false]);
|
||||
|
@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\AutowiringTypes;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface as FrameworkBundleEngineInterface;
|
||||
use Symfony\Component\Templating\EngineInterface;
|
||||
|
||||
/**
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
class TemplatingServices
|
||||
{
|
||||
private $frameworkBundleEngine;
|
||||
private $engine;
|
||||
|
||||
public function __construct(FrameworkBundleEngineInterface $frameworkBundleEngine, EngineInterface $engine)
|
||||
{
|
||||
$this->frameworkBundleEngine = $frameworkBundleEngine;
|
||||
$this->engine = $engine;
|
||||
}
|
||||
|
||||
public function getFrameworkBundleEngine()
|
||||
{
|
||||
return $this->frameworkBundleEngine;
|
||||
}
|
||||
|
||||
public function getEngine()
|
||||
{
|
||||
return $this->engine;
|
||||
}
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
imports:
|
||||
- { resource: ../config/default.yml }
|
||||
|
||||
services:
|
||||
_defaults: { public: true }
|
||||
test.autowiring_types.autowired_services:
|
||||
class: Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\AutowiringTypes\TemplatingServices
|
||||
autowire: true
|
||||
|
||||
framework:
|
||||
templating:
|
||||
engines: ['php']
|
@ -1,128 +0,0 @@
|
||||
<?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\Templating;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bundle\FrameworkBundle\Templating\DelegatingEngine;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
class DelegatingEngineTest extends TestCase
|
||||
{
|
||||
public function testSupportsRetrievesEngineFromTheContainer()
|
||||
{
|
||||
$container = $this->getContainerMock([
|
||||
'engine.first' => $this->getEngineMock('template.php', false),
|
||||
'engine.second' => $this->getEngineMock('template.php', true),
|
||||
]);
|
||||
|
||||
$delegatingEngine = new DelegatingEngine($container, ['engine.first', 'engine.second']);
|
||||
|
||||
$this->assertTrue($delegatingEngine->supports('template.php'));
|
||||
}
|
||||
|
||||
public function testGetExistingEngine()
|
||||
{
|
||||
$firstEngine = $this->getEngineMock('template.php', false);
|
||||
$secondEngine = $this->getEngineMock('template.php', true);
|
||||
$container = $this->getContainerMock([
|
||||
'engine.first' => $firstEngine,
|
||||
'engine.second' => $secondEngine,
|
||||
]);
|
||||
|
||||
$delegatingEngine = new DelegatingEngine($container, ['engine.first', 'engine.second']);
|
||||
|
||||
$this->assertSame($secondEngine, $delegatingEngine->getEngine('template.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \RuntimeException
|
||||
* @expectedExceptionMessage No engine is able to work with the template "template.php"
|
||||
*/
|
||||
public function testGetInvalidEngine()
|
||||
{
|
||||
$firstEngine = $this->getEngineMock('template.php', false);
|
||||
$secondEngine = $this->getEngineMock('template.php', false);
|
||||
$container = $this->getContainerMock([
|
||||
'engine.first' => $firstEngine,
|
||||
'engine.second' => $secondEngine,
|
||||
]);
|
||||
|
||||
$delegatingEngine = new DelegatingEngine($container, ['engine.first', 'engine.second']);
|
||||
$delegatingEngine->getEngine('template.php');
|
||||
}
|
||||
|
||||
public function testRenderResponseWithFrameworkEngine()
|
||||
{
|
||||
$response = new Response();
|
||||
$engine = $this->getFrameworkEngineMock('template.php', true);
|
||||
$engine->expects($this->once())
|
||||
->method('renderResponse')
|
||||
->with('template.php', ['foo' => 'bar'])
|
||||
->willReturn($response);
|
||||
$container = $this->getContainerMock(['engine' => $engine]);
|
||||
|
||||
$delegatingEngine = new DelegatingEngine($container, ['engine']);
|
||||
|
||||
$this->assertSame($response, $delegatingEngine->renderResponse('template.php', ['foo' => 'bar']));
|
||||
}
|
||||
|
||||
public function testRenderResponseWithTemplatingEngine()
|
||||
{
|
||||
$engine = $this->getEngineMock('template.php', true);
|
||||
$container = $this->getContainerMock(['engine' => $engine]);
|
||||
$delegatingEngine = new DelegatingEngine($container, ['engine']);
|
||||
|
||||
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $delegatingEngine->renderResponse('template.php', ['foo' => 'bar']));
|
||||
}
|
||||
|
||||
private function getEngineMock($template, $supports)
|
||||
{
|
||||
$engine = $this->getMockBuilder('Symfony\Component\Templating\EngineInterface')->getMock();
|
||||
|
||||
$engine->expects($this->once())
|
||||
->method('supports')
|
||||
->with($template)
|
||||
->willReturn($supports);
|
||||
|
||||
return $engine;
|
||||
}
|
||||
|
||||
private function getFrameworkEngineMock($template, $supports)
|
||||
{
|
||||
$engine = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface')->getMock();
|
||||
|
||||
$engine->expects($this->once())
|
||||
->method('supports')
|
||||
->with($template)
|
||||
->willReturn($supports);
|
||||
|
||||
return $engine;
|
||||
}
|
||||
|
||||
private function getContainerMock($services)
|
||||
{
|
||||
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
|
||||
|
||||
$i = 0;
|
||||
foreach ($services as $id => $service) {
|
||||
$container->expects($this->at($i++))
|
||||
->method('get')
|
||||
->with($id)
|
||||
->willReturn($service);
|
||||
}
|
||||
|
||||
return $container;
|
||||
}
|
||||
}
|
@ -1,109 +0,0 @@
|
||||
<?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\Templating;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Templating\GlobalVariables;
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
class GlobalVariablesTest extends TestCase
|
||||
{
|
||||
private $container;
|
||||
private $globals;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->container = new Container();
|
||||
$this->globals = new GlobalVariables($this->container);
|
||||
}
|
||||
|
||||
public function testGetTokenNoTokenStorage()
|
||||
{
|
||||
$this->assertNull($this->globals->getToken());
|
||||
}
|
||||
|
||||
public function testGetTokenNoToken()
|
||||
{
|
||||
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
|
||||
$this->container->set('security.token_storage', $tokenStorage);
|
||||
$this->assertNull($this->globals->getToken());
|
||||
}
|
||||
|
||||
public function testGetToken()
|
||||
{
|
||||
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
|
||||
|
||||
$this->container->set('security.token_storage', $tokenStorage);
|
||||
|
||||
$tokenStorage
|
||||
->expects($this->once())
|
||||
->method('getToken')
|
||||
->willReturn('token');
|
||||
|
||||
$this->assertSame('token', $this->globals->getToken());
|
||||
}
|
||||
|
||||
public function testGetUserNoTokenStorage()
|
||||
{
|
||||
$this->assertNull($this->globals->getUser());
|
||||
}
|
||||
|
||||
public function testGetUserNoToken()
|
||||
{
|
||||
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
|
||||
$this->container->set('security.token_storage', $tokenStorage);
|
||||
$this->assertNull($this->globals->getUser());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getUserProvider
|
||||
*/
|
||||
public function testGetUser($user, $expectedUser)
|
||||
{
|
||||
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
|
||||
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
|
||||
|
||||
$this->container->set('security.token_storage', $tokenStorage);
|
||||
|
||||
$token
|
||||
->expects($this->once())
|
||||
->method('getUser')
|
||||
->willReturn($user);
|
||||
|
||||
$tokenStorage
|
||||
->expects($this->once())
|
||||
->method('getToken')
|
||||
->willReturn($token);
|
||||
|
||||
$this->assertSame($expectedUser, $this->globals->getUser());
|
||||
}
|
||||
|
||||
public function getUserProvider()
|
||||
{
|
||||
$user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
|
||||
$std = new \stdClass();
|
||||
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
|
||||
|
||||
return [
|
||||
[$user, $user],
|
||||
[$std, $std],
|
||||
[$token, $token],
|
||||
['Anon.', null],
|
||||
[null, null],
|
||||
[10, null],
|
||||
[true, null],
|
||||
];
|
||||
}
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
<?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\Templating\Helper;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bundle\FrameworkBundle\Templating\Helper\AssetsHelper;
|
||||
use Symfony\Component\Asset\Package;
|
||||
use Symfony\Component\Asset\Packages;
|
||||
use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy;
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
class AssetsHelperTest extends TestCase
|
||||
{
|
||||
private $helper;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$fooPackage = new Package(new StaticVersionStrategy('42', '%s?v=%s'));
|
||||
$barPackage = new Package(new StaticVersionStrategy('22', '%s?%s'));
|
||||
|
||||
$packages = new Packages($fooPackage, ['bar' => $barPackage]);
|
||||
|
||||
$this->helper = new AssetsHelper($packages);
|
||||
}
|
||||
|
||||
public function testGetUrl()
|
||||
{
|
||||
$this->assertEquals('me.png?v=42', $this->helper->getUrl('me.png'));
|
||||
$this->assertEquals('me.png?22', $this->helper->getUrl('me.png', 'bar'));
|
||||
}
|
||||
|
||||
public function testGetVersion()
|
||||
{
|
||||
$this->assertEquals('42', $this->helper->getVersion('/'));
|
||||
$this->assertEquals('22', $this->helper->getVersion('/', 'bar'));
|
||||
}
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
<?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\Templating\Helper\Fixtures;
|
||||
|
||||
use Symfony\Component\Templating\TemplateNameParserInterface;
|
||||
use Symfony\Component\Templating\TemplateReference;
|
||||
|
||||
class StubTemplateNameParser implements TemplateNameParserInterface
|
||||
{
|
||||
private $root;
|
||||
|
||||
private $rootTheme;
|
||||
|
||||
public function __construct($root, $rootTheme)
|
||||
{
|
||||
$this->root = $root;
|
||||
$this->rootTheme = $rootTheme;
|
||||
}
|
||||
|
||||
public function parse($name)
|
||||
{
|
||||
list($bundle, $controller, $template) = explode(':', $name, 3);
|
||||
|
||||
if ('_' == $template[0]) {
|
||||
$path = $this->rootTheme.'/Custom/'.$template;
|
||||
} elseif ('TestBundle' === $bundle) {
|
||||
$path = $this->rootTheme.'/'.$controller.'/'.$template;
|
||||
} else {
|
||||
$path = $this->root.'/'.$controller.'/'.$template;
|
||||
}
|
||||
|
||||
return new TemplateReference($path, 'php');
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
<?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\Templating\Helper\Fixtures;
|
||||
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
class StubTranslator implements TranslatorInterface
|
||||
{
|
||||
public function trans($id, array $parameters = [], $domain = null, $locale = null)
|
||||
{
|
||||
return '[trans]'.strtr($id, $parameters).'[/trans]';
|
||||
}
|
||||
}
|
@ -1,264 +0,0 @@
|
||||
<?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\Templating\Helper;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Templating\Helper\TranslatorHelper;
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper\Fixtures\StubTemplateNameParser;
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper\Fixtures\StubTranslator;
|
||||
use Symfony\Component\Form\Extension\Templating\TemplatingExtension;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\Form\Tests\AbstractDivLayoutTest;
|
||||
use Symfony\Component\Templating\Loader\FilesystemLoader;
|
||||
use Symfony\Component\Templating\PhpEngine;
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
class FormHelperDivLayoutTest extends AbstractDivLayoutTest
|
||||
{
|
||||
/**
|
||||
* @var PhpEngine
|
||||
*/
|
||||
protected $engine;
|
||||
|
||||
protected static $supportedFeatureSetVersion = 403;
|
||||
|
||||
protected function getExtensions()
|
||||
{
|
||||
// should be moved to the Form component once absolute file paths are supported
|
||||
// by the default name parser in the Templating component
|
||||
$reflClass = new \ReflectionClass('Symfony\Bundle\FrameworkBundle\FrameworkBundle');
|
||||
$root = realpath(\dirname($reflClass->getFileName()).'/Resources/views');
|
||||
$rootTheme = realpath(__DIR__.'/Resources');
|
||||
$templateNameParser = new StubTemplateNameParser($root, $rootTheme);
|
||||
$loader = new FilesystemLoader([]);
|
||||
|
||||
$this->engine = new PhpEngine($templateNameParser, $loader);
|
||||
$this->engine->addGlobal('global', '');
|
||||
$this->engine->setHelpers([
|
||||
new TranslatorHelper(new StubTranslator()),
|
||||
]);
|
||||
|
||||
return array_merge(parent::getExtensions(), [
|
||||
new TemplatingExtension($this->engine, $this->csrfTokenManager, [
|
||||
'FrameworkBundle:Form',
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
$this->engine = null;
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testStartTagHasNoActionAttributeWhenActionIsEmpty()
|
||||
{
|
||||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [
|
||||
'method' => 'get',
|
||||
'action' => '',
|
||||
]);
|
||||
|
||||
$html = $this->renderStart($form->createView());
|
||||
|
||||
$this->assertSame('<form name="form" method="get">', $html);
|
||||
}
|
||||
|
||||
public function testStartTagHasActionAttributeWhenActionIsZero()
|
||||
{
|
||||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [
|
||||
'method' => 'get',
|
||||
'action' => '0',
|
||||
]);
|
||||
|
||||
$html = $this->renderStart($form->createView());
|
||||
|
||||
$this->assertSame('<form name="form" method="get" action="0">', $html);
|
||||
}
|
||||
|
||||
public function testMoneyWidgetInIso()
|
||||
{
|
||||
$this->engine->setCharset('ISO-8859-1');
|
||||
|
||||
$view = $this->factory
|
||||
->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\MoneyType')
|
||||
->createView()
|
||||
;
|
||||
|
||||
$this->assertSame('€ <input type="text" id="name" name="name" required="required" />', $this->renderWidget($view));
|
||||
}
|
||||
|
||||
public function testHelpAttr()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
|
||||
'help' => 'Help text test!',
|
||||
'help_attr' => [
|
||||
'class' => 'class-test',
|
||||
],
|
||||
]);
|
||||
$view = $form->createView();
|
||||
$html = $this->renderHelp($view);
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/p
|
||||
[@id="name_help"]
|
||||
[@class="class-test help-text"]
|
||||
[.="[trans]Help text test![/trans]"]
|
||||
'
|
||||
);
|
||||
}
|
||||
|
||||
public function testHelpHtmlDefaultIsFalse()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
|
||||
'help' => 'Help <b>text</b> test!',
|
||||
]);
|
||||
$view = $form->createView();
|
||||
$html = $this->renderHelp($view);
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/p
|
||||
[@id="name_help"]
|
||||
[@class="help-text"]
|
||||
[.="[trans]Help <b>text</b> test![/trans]"]
|
||||
'
|
||||
);
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/p
|
||||
[@id="name_help"]
|
||||
[@class="help-text"]
|
||||
/b
|
||||
[.="text"]
|
||||
', 0
|
||||
);
|
||||
}
|
||||
|
||||
public function testHelpHtmlIsFalse()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
|
||||
'help' => 'Help <b>text</b> test!',
|
||||
'help_html' => false,
|
||||
]);
|
||||
$view = $form->createView();
|
||||
$html = $this->renderHelp($view);
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/p
|
||||
[@id="name_help"]
|
||||
[@class="help-text"]
|
||||
[.="[trans]Help <b>text</b> test![/trans]"]
|
||||
'
|
||||
);
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/p
|
||||
[@id="name_help"]
|
||||
[@class="help-text"]
|
||||
/b
|
||||
[.="text"]
|
||||
', 0
|
||||
);
|
||||
}
|
||||
|
||||
public function testHelpHtmlIsTrue()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
|
||||
'help' => 'Help <b>text</b> test!',
|
||||
'help_html' => true,
|
||||
]);
|
||||
$view = $form->createView();
|
||||
$html = $this->renderHelp($view);
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/p
|
||||
[@id="name_help"]
|
||||
[@class="help-text"]
|
||||
[.="[trans]Help <b>text</b> test![/trans]"]
|
||||
', 0
|
||||
);
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/p
|
||||
[@id="name_help"]
|
||||
[@class="help-text"]
|
||||
/b
|
||||
[.="text"]
|
||||
'
|
||||
);
|
||||
}
|
||||
|
||||
protected function renderForm(FormView $view, array $vars = [])
|
||||
{
|
||||
return (string) $this->engine->get('form')->form($view, $vars);
|
||||
}
|
||||
|
||||
protected function renderLabel(FormView $view, $label = null, array $vars = [])
|
||||
{
|
||||
return (string) $this->engine->get('form')->label($view, $label, $vars);
|
||||
}
|
||||
|
||||
protected function renderHelp(FormView $view)
|
||||
{
|
||||
return (string) $this->engine->get('form')->help($view);
|
||||
}
|
||||
|
||||
protected function renderErrors(FormView $view)
|
||||
{
|
||||
return (string) $this->engine->get('form')->errors($view);
|
||||
}
|
||||
|
||||
protected function renderWidget(FormView $view, array $vars = [])
|
||||
{
|
||||
return (string) $this->engine->get('form')->widget($view, $vars);
|
||||
}
|
||||
|
||||
protected function renderRow(FormView $view, array $vars = [])
|
||||
{
|
||||
return (string) $this->engine->get('form')->row($view, $vars);
|
||||
}
|
||||
|
||||
protected function renderRest(FormView $view, array $vars = [])
|
||||
{
|
||||
return (string) $this->engine->get('form')->rest($view, $vars);
|
||||
}
|
||||
|
||||
protected function renderStart(FormView $view, array $vars = [])
|
||||
{
|
||||
return (string) $this->engine->get('form')->start($view, $vars);
|
||||
}
|
||||
|
||||
protected function renderEnd(FormView $view, array $vars = [])
|
||||
{
|
||||
return (string) $this->engine->get('form')->end($view, $vars);
|
||||
}
|
||||
|
||||
protected function setTheme(FormView $view, array $themes, $useDefaultThemes = true)
|
||||
{
|
||||
$this->engine->get('form')->setTheme($view, $themes, $useDefaultThemes);
|
||||
}
|
||||
|
||||
public static function themeBlockInheritanceProvider()
|
||||
{
|
||||
return [
|
||||
[['TestBundle:Parent']],
|
||||
];
|
||||
}
|
||||
|
||||
public static function themeInheritanceProvider()
|
||||
{
|
||||
return [
|
||||
[['TestBundle:Parent'], ['TestBundle:Child']],
|
||||
];
|
||||
}
|
||||
}
|
@ -1,159 +0,0 @@
|
||||
<?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\Templating\Helper;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Templating\Helper\TranslatorHelper;
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper\Fixtures\StubTemplateNameParser;
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper\Fixtures\StubTranslator;
|
||||
use Symfony\Component\Form\Extension\Templating\TemplatingExtension;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\Form\Tests\AbstractTableLayoutTest;
|
||||
use Symfony\Component\Templating\Loader\FilesystemLoader;
|
||||
use Symfony\Component\Templating\PhpEngine;
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
class FormHelperTableLayoutTest extends AbstractTableLayoutTest
|
||||
{
|
||||
/**
|
||||
* @var PhpEngine
|
||||
*/
|
||||
protected $engine;
|
||||
|
||||
protected static $supportedFeatureSetVersion = 403;
|
||||
|
||||
public function testStartTagHasNoActionAttributeWhenActionIsEmpty()
|
||||
{
|
||||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [
|
||||
'method' => 'get',
|
||||
'action' => '',
|
||||
]);
|
||||
|
||||
$html = $this->renderStart($form->createView());
|
||||
|
||||
$this->assertSame('<form name="form" method="get">', $html);
|
||||
}
|
||||
|
||||
public function testStartTagHasActionAttributeWhenActionIsZero()
|
||||
{
|
||||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [
|
||||
'method' => 'get',
|
||||
'action' => '0',
|
||||
]);
|
||||
|
||||
$html = $this->renderStart($form->createView());
|
||||
|
||||
$this->assertSame('<form name="form" method="get" action="0">', $html);
|
||||
}
|
||||
|
||||
public function testHelpAttr()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
|
||||
'help' => 'Help text test!',
|
||||
'help_attr' => [
|
||||
'class' => 'class-test',
|
||||
],
|
||||
]);
|
||||
$view = $form->createView();
|
||||
$html = $this->renderHelp($view);
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/p
|
||||
[@id="name_help"]
|
||||
[@class="class-test help-text"]
|
||||
[.="[trans]Help text test![/trans]"]
|
||||
'
|
||||
);
|
||||
}
|
||||
|
||||
protected function getExtensions()
|
||||
{
|
||||
// should be moved to the Form component once absolute file paths are supported
|
||||
// by the default name parser in the Templating component
|
||||
$reflClass = new \ReflectionClass('Symfony\Bundle\FrameworkBundle\FrameworkBundle');
|
||||
$root = realpath(\dirname($reflClass->getFileName()).'/Resources/views');
|
||||
$rootTheme = realpath(__DIR__.'/Resources');
|
||||
$templateNameParser = new StubTemplateNameParser($root, $rootTheme);
|
||||
$loader = new FilesystemLoader([]);
|
||||
|
||||
$this->engine = new PhpEngine($templateNameParser, $loader);
|
||||
$this->engine->addGlobal('global', '');
|
||||
$this->engine->setHelpers([
|
||||
new TranslatorHelper(new StubTranslator()),
|
||||
]);
|
||||
|
||||
return array_merge(parent::getExtensions(), [
|
||||
new TemplatingExtension($this->engine, $this->csrfTokenManager, [
|
||||
'FrameworkBundle:Form',
|
||||
'FrameworkBundle:FormTable',
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
$this->engine = null;
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
protected function renderForm(FormView $view, array $vars = [])
|
||||
{
|
||||
return (string) $this->engine->get('form')->form($view, $vars);
|
||||
}
|
||||
|
||||
protected function renderLabel(FormView $view, $label = null, array $vars = [])
|
||||
{
|
||||
return (string) $this->engine->get('form')->label($view, $label, $vars);
|
||||
}
|
||||
|
||||
protected function renderHelp(FormView $view)
|
||||
{
|
||||
return (string) $this->engine->get('form')->help($view);
|
||||
}
|
||||
|
||||
protected function renderErrors(FormView $view)
|
||||
{
|
||||
return (string) $this->engine->get('form')->errors($view);
|
||||
}
|
||||
|
||||
protected function renderWidget(FormView $view, array $vars = [])
|
||||
{
|
||||
return (string) $this->engine->get('form')->widget($view, $vars);
|
||||
}
|
||||
|
||||
protected function renderRow(FormView $view, array $vars = [])
|
||||
{
|
||||
return (string) $this->engine->get('form')->row($view, $vars);
|
||||
}
|
||||
|
||||
protected function renderRest(FormView $view, array $vars = [])
|
||||
{
|
||||
return (string) $this->engine->get('form')->rest($view, $vars);
|
||||
}
|
||||
|
||||
protected function renderStart(FormView $view, array $vars = [])
|
||||
{
|
||||
return (string) $this->engine->get('form')->start($view, $vars);
|
||||
}
|
||||
|
||||
protected function renderEnd(FormView $view, array $vars = [])
|
||||
{
|
||||
return (string) $this->engine->get('form')->end($view, $vars);
|
||||
}
|
||||
|
||||
protected function setTheme(FormView $view, array $themes, $useDefaultThemes = true)
|
||||
{
|
||||
$this->engine->get('form')->setTheme($view, $themes, $useDefaultThemes);
|
||||
}
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
<?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\Templating\Helper;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bundle\FrameworkBundle\Templating\Helper\RequestHelper;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
class RequestHelperTest extends TestCase
|
||||
{
|
||||
protected $requestStack;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->requestStack = new RequestStack();
|
||||
$request = new Request();
|
||||
$request->initialize(['foobar' => 'bar']);
|
||||
$this->requestStack->push($request);
|
||||
}
|
||||
|
||||
public function testGetParameter()
|
||||
{
|
||||
$helper = new RequestHelper($this->requestStack);
|
||||
|
||||
$this->assertEquals('bar', $helper->getParameter('foobar'));
|
||||
$this->assertEquals('foo', $helper->getParameter('bar', 'foo'));
|
||||
|
||||
$this->assertNull($helper->getParameter('foo'));
|
||||
}
|
||||
|
||||
public function testGetLocale()
|
||||
{
|
||||
$helper = new RequestHelper($this->requestStack);
|
||||
|
||||
$this->assertEquals('en', $helper->getLocale());
|
||||
}
|
||||
|
||||
public function testGetName()
|
||||
{
|
||||
$helper = new RequestHelper($this->requestStack);
|
||||
|
||||
$this->assertEquals('request', $helper->getName());
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
<label><?php echo $global; ?>child</label>
|
@ -1,2 +0,0 @@
|
||||
<?php if (!$label) { $label = $view['form']->humanize($name); } ?>
|
||||
<label>Custom name label: <?php echo $view->escape($view['translator']->trans($label, [], $translation_domain)) ?></label>
|
@ -1,4 +0,0 @@
|
||||
<?php if (!$label) {
|
||||
$label = $view['form']->humanize($name);
|
||||
} ?>
|
||||
<label>Custom label: <?php echo $view->escape($view['translator']->trans($label, [], $translation_domain)) ?></label>
|
@ -1,3 +0,0 @@
|
||||
<div id="container">
|
||||
<?php echo $view['form']->widget($form) ?>
|
||||
</div>
|
@ -1 +0,0 @@
|
||||
<label>parent</label>
|
@ -1,2 +0,0 @@
|
||||
<?php $type = isset($type) ? $type : 'text'; ?>
|
||||
<input type="<?php echo $type; ?>" <?php $view['form']->block($form, 'widget_attributes'); ?> value="<?php echo $value; ?>" rel="theme" />
|
@ -1,78 +0,0 @@
|
||||
<?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\Templating\Helper;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bundle\FrameworkBundle\Templating\Helper\SessionHelper;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\HttpFoundation\Session\Session;
|
||||
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
class SessionHelperTest extends TestCase
|
||||
{
|
||||
protected $requestStack;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$request = new Request();
|
||||
|
||||
$session = new Session(new MockArraySessionStorage());
|
||||
$session->set('foobar', 'bar');
|
||||
$session->getFlashBag()->set('notice', 'bar');
|
||||
|
||||
$request->setSession($session);
|
||||
|
||||
$this->requestStack = new RequestStack();
|
||||
$this->requestStack->push($request);
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
$this->requestStack = null;
|
||||
}
|
||||
|
||||
public function testFlash()
|
||||
{
|
||||
$helper = new SessionHelper($this->requestStack);
|
||||
|
||||
$this->assertTrue($helper->hasFlash('notice'));
|
||||
|
||||
$this->assertEquals(['bar'], $helper->getFlash('notice'));
|
||||
}
|
||||
|
||||
public function testGetFlashes()
|
||||
{
|
||||
$helper = new SessionHelper($this->requestStack);
|
||||
$this->assertEquals(['notice' => ['bar']], $helper->getFlashes());
|
||||
}
|
||||
|
||||
public function testGet()
|
||||
{
|
||||
$helper = new SessionHelper($this->requestStack);
|
||||
|
||||
$this->assertEquals('bar', $helper->get('foobar'));
|
||||
$this->assertEquals('foo', $helper->get('bar', 'foo'));
|
||||
|
||||
$this->assertNull($helper->get('foo'));
|
||||
}
|
||||
|
||||
public function testGetName()
|
||||
{
|
||||
$helper = new SessionHelper($this->requestStack);
|
||||
|
||||
$this->assertEquals('session', $helper->getName());
|
||||
}
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
<?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\Templating\Helper;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bundle\FrameworkBundle\Templating\Helper\StopwatchHelper;
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
class StopwatchHelperTest extends TestCase
|
||||
{
|
||||
public function testDevEnvironment()
|
||||
{
|
||||
$stopwatch = $this->getMockBuilder('Symfony\Component\Stopwatch\Stopwatch')->getMock();
|
||||
$stopwatch->expects($this->once())
|
||||
->method('start')
|
||||
->with('foo');
|
||||
|
||||
$helper = new StopwatchHelper($stopwatch);
|
||||
$helper->start('foo');
|
||||
}
|
||||
|
||||
public function testProdEnvironment()
|
||||
{
|
||||
$helper = new StopwatchHelper(null);
|
||||
$helper->start('foo');
|
||||
|
||||
// add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above
|
||||
// can be executed without throwing any exceptions
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
}
|
@ -1,101 +0,0 @@
|
||||
<?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\Templating\Loader;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Templating\Loader\TemplateLocator;
|
||||
use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference;
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
class TemplateLocatorTest extends TestCase
|
||||
{
|
||||
public function testLocateATemplate()
|
||||
{
|
||||
$template = new TemplateReference('bundle', 'controller', 'name', 'format', 'engine');
|
||||
|
||||
$fileLocator = $this->getFileLocator();
|
||||
|
||||
$fileLocator
|
||||
->expects($this->once())
|
||||
->method('locate')
|
||||
->with($template->getPath())
|
||||
->willReturn('/path/to/template')
|
||||
;
|
||||
|
||||
$locator = new TemplateLocator($fileLocator);
|
||||
|
||||
$this->assertEquals('/path/to/template', $locator->locate($template));
|
||||
|
||||
// Assert cache is used as $fileLocator->locate should be called only once
|
||||
$this->assertEquals('/path/to/template', $locator->locate($template));
|
||||
}
|
||||
|
||||
public function testLocateATemplateFromCacheDir()
|
||||
{
|
||||
$template = new TemplateReference('bundle', 'controller', 'name', 'format', 'engine');
|
||||
|
||||
$fileLocator = $this->getFileLocator();
|
||||
|
||||
$locator = new TemplateLocator($fileLocator, __DIR__.'/../../Fixtures');
|
||||
|
||||
$this->assertEquals(realpath(__DIR__.'/../../Fixtures/Resources/views/this.is.a.template.format.engine'), $locator->locate($template));
|
||||
}
|
||||
|
||||
public function testThrowsExceptionWhenTemplateNotFound()
|
||||
{
|
||||
$template = new TemplateReference('bundle', 'controller', 'name', 'format', 'engine');
|
||||
|
||||
$fileLocator = $this->getFileLocator();
|
||||
|
||||
$errorMessage = 'FileLocator exception message';
|
||||
|
||||
$fileLocator
|
||||
->expects($this->once())
|
||||
->method('locate')
|
||||
->willThrowException(new \InvalidArgumentException($errorMessage))
|
||||
;
|
||||
|
||||
$locator = new TemplateLocator($fileLocator);
|
||||
|
||||
try {
|
||||
$locator->locate($template);
|
||||
$this->fail('->locate() should throw an exception when the file is not found.');
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
$this->assertContains(
|
||||
$errorMessage,
|
||||
$e->getMessage(),
|
||||
'TemplateLocator exception should propagate the FileLocator exception message'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testThrowsAnExceptionWhenTemplateIsNotATemplateReferenceInterface()
|
||||
{
|
||||
$locator = new TemplateLocator($this->getFileLocator());
|
||||
$locator->locate('template');
|
||||
}
|
||||
|
||||
protected function getFileLocator()
|
||||
{
|
||||
return $this
|
||||
->getMockBuilder('Symfony\Component\Config\FileLocator')
|
||||
->setMethods(['locate'])
|
||||
->setConstructorArgs(['/path/to/fallback'])
|
||||
->getMock()
|
||||
;
|
||||
}
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
<?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\Templating;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Templating\GlobalVariables;
|
||||
use Symfony\Bundle\FrameworkBundle\Templating\PhpEngine;
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\HttpFoundation\Session\Session;
|
||||
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
|
||||
use Symfony\Component\Templating\TemplateNameParser;
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
class PhpEngineTest extends TestCase
|
||||
{
|
||||
public function testEvaluateAddsAppGlobal()
|
||||
{
|
||||
$container = $this->getContainer();
|
||||
$loader = $this->getMockForAbstractClass('Symfony\Component\Templating\Loader\Loader');
|
||||
$engine = new PhpEngine(new TemplateNameParser(), $container, $loader, $app = new GlobalVariables($container));
|
||||
$globals = $engine->getGlobals();
|
||||
$this->assertSame($app, $globals['app']);
|
||||
}
|
||||
|
||||
public function testEvaluateWithoutAvailableRequest()
|
||||
{
|
||||
$container = new Container();
|
||||
$loader = $this->getMockForAbstractClass('Symfony\Component\Templating\Loader\Loader');
|
||||
$engine = new PhpEngine(new TemplateNameParser(), $container, $loader, new GlobalVariables($container));
|
||||
|
||||
$this->assertFalse($container->has('request_stack'));
|
||||
$globals = $engine->getGlobals();
|
||||
$this->assertEmpty($globals['app']->getRequest());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testGetInvalidHelper()
|
||||
{
|
||||
$container = $this->getContainer();
|
||||
$loader = $this->getMockForAbstractClass('Symfony\Component\Templating\Loader\Loader');
|
||||
$engine = new PhpEngine(new TemplateNameParser(), $container, $loader);
|
||||
|
||||
$engine->get('non-existing-helper');
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Container with a Session-containing Request service.
|
||||
*
|
||||
* @return Container
|
||||
*/
|
||||
protected function getContainer()
|
||||
{
|
||||
$container = new Container();
|
||||
$session = new Session(new MockArraySessionStorage());
|
||||
$request = new Request();
|
||||
$stack = new RequestStack();
|
||||
$stack->push($request);
|
||||
|
||||
$request->setSession($session);
|
||||
$container->set('request_stack', $stack);
|
||||
|
||||
return $container;
|
||||
}
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
<?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\Templating;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Templating\TemplateFilenameParser;
|
||||
use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference;
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
class TemplateFilenameParserTest extends TestCase
|
||||
{
|
||||
protected $parser;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser = new TemplateFilenameParser();
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
$this->parser = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getFilenameToTemplateProvider
|
||||
*/
|
||||
public function testParseFromFilename($file, $ref)
|
||||
{
|
||||
$template = $this->parser->parse($file);
|
||||
|
||||
if (false === $ref) {
|
||||
$this->assertFalse($template);
|
||||
} else {
|
||||
$this->assertEquals($template->getLogicalName(), $ref->getLogicalName());
|
||||
}
|
||||
}
|
||||
|
||||
public function getFilenameToTemplateProvider()
|
||||
{
|
||||
return [
|
||||
['/path/to/section/name.format.engine', new TemplateReference('', '/path/to/section', 'name', 'format', 'engine')],
|
||||
['\\path\\to\\section\\name.format.engine', new TemplateReference('', '/path/to/section', 'name', 'format', 'engine')],
|
||||
['name.format.engine', new TemplateReference('', '', 'name', 'format', 'engine')],
|
||||
['name.format', false],
|
||||
['name', false],
|
||||
];
|
||||
}
|
||||
}
|
@ -1,87 +0,0 @@
|
||||
<?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\Templating;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Templating\TemplateNameParser;
|
||||
use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference;
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
||||
use Symfony\Component\Templating\TemplateReference as BaseTemplateReference;
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
class TemplateNameParserTest extends TestCase
|
||||
{
|
||||
protected $parser;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
|
||||
$kernel
|
||||
->expects($this->any())
|
||||
->method('getBundle')
|
||||
->willReturnCallback(function ($bundle) {
|
||||
if (\in_array($bundle, ['SensioFooBundle', 'SensioCmsFooBundle', 'FooBundle'])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException();
|
||||
})
|
||||
;
|
||||
$this->parser = new TemplateNameParser($kernel);
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
$this->parser = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider parseProvider
|
||||
*/
|
||||
public function testParse($name, $logicalName, $path, $ref)
|
||||
{
|
||||
$template = $this->parser->parse($name);
|
||||
|
||||
$this->assertSame($ref->getLogicalName(), $template->getLogicalName());
|
||||
$this->assertSame($logicalName, $template->getLogicalName());
|
||||
$this->assertSame($path, $template->getPath());
|
||||
}
|
||||
|
||||
public function parseProvider()
|
||||
{
|
||||
return [
|
||||
['FooBundle:Post:index.html.php', 'FooBundle:Post:index.html.php', '@FooBundle/Resources/views/Post/index.html.php', new TemplateReference('FooBundle', 'Post', 'index', 'html', 'php')],
|
||||
['FooBundle:Post:index.html.twig', 'FooBundle:Post:index.html.twig', '@FooBundle/Resources/views/Post/index.html.twig', new TemplateReference('FooBundle', 'Post', 'index', 'html', 'twig')],
|
||||
['FooBundle:Post:index.xml.php', 'FooBundle:Post:index.xml.php', '@FooBundle/Resources/views/Post/index.xml.php', new TemplateReference('FooBundle', 'Post', 'index', 'xml', 'php')],
|
||||
['SensioFooBundle:Post:index.html.php', 'SensioFooBundle:Post:index.html.php', '@SensioFooBundle/Resources/views/Post/index.html.php', new TemplateReference('SensioFooBundle', 'Post', 'index', 'html', 'php')],
|
||||
['SensioCmsFooBundle:Post:index.html.php', 'SensioCmsFooBundle:Post:index.html.php', '@SensioCmsFooBundle/Resources/views/Post/index.html.php', new TemplateReference('SensioCmsFooBundle', 'Post', 'index', 'html', 'php')],
|
||||
[':Post:index.html.php', ':Post:index.html.php', 'views/Post/index.html.php', new TemplateReference('', 'Post', 'index', 'html', 'php')],
|
||||
['::index.html.php', '::index.html.php', 'views/index.html.php', new TemplateReference('', '', 'index', 'html', 'php')],
|
||||
['index.html.php', '::index.html.php', 'views/index.html.php', new TemplateReference('', '', 'index', 'html', 'php')],
|
||||
['FooBundle:Post:foo.bar.index.html.php', 'FooBundle:Post:foo.bar.index.html.php', '@FooBundle/Resources/views/Post/foo.bar.index.html.php', new TemplateReference('FooBundle', 'Post', 'foo.bar.index', 'html', 'php')],
|
||||
['@FooBundle/Resources/views/layout.html.twig', '@FooBundle/Resources/views/layout.html.twig', '@FooBundle/Resources/views/layout.html.twig', new BaseTemplateReference('@FooBundle/Resources/views/layout.html.twig', 'twig')],
|
||||
['@FooBundle/Foo/layout.html.twig', '@FooBundle/Foo/layout.html.twig', '@FooBundle/Foo/layout.html.twig', new BaseTemplateReference('@FooBundle/Foo/layout.html.twig', 'twig')],
|
||||
['name.twig', 'name.twig', 'name.twig', new BaseTemplateReference('name.twig', 'twig')],
|
||||
['name', 'name', 'name', new BaseTemplateReference('name')],
|
||||
['default/index.html.php', '::default/index.html.php', 'views/default/index.html.php', new TemplateReference(null, null, 'default/index', 'html', 'php')],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testParseValidNameWithNotFoundBundle()
|
||||
{
|
||||
$this->parser->parse('BarBundle:Post:index.html.php');
|
||||
}
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
<?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\Templating;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference;
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
class TemplateReferenceTest extends TestCase
|
||||
{
|
||||
public function testGetPathWorksWithNamespacedControllers()
|
||||
{
|
||||
$reference = new TemplateReference('AcmeBlogBundle', 'Admin\Post', 'index', 'html', 'twig');
|
||||
|
||||
$this->assertSame(
|
||||
'@AcmeBlogBundle/Resources/views/Admin/Post/index.html.twig',
|
||||
$reference->getPath()
|
||||
);
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
<?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\Templating;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference;
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
class TemplateTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider getTemplateToPathProvider
|
||||
*/
|
||||
public function testGetPathForTemplate($template, $path)
|
||||
{
|
||||
$this->assertSame($template->getPath(), $path);
|
||||
}
|
||||
|
||||
public function getTemplateToPathProvider()
|
||||
{
|
||||
return [
|
||||
[new TemplateReference('FooBundle', 'Post', 'index', 'html', 'php'), '@FooBundle/Resources/views/Post/index.html.php'],
|
||||
[new TemplateReference('FooBundle', '', 'index', 'html', 'twig'), '@FooBundle/Resources/views/index.html.twig'],
|
||||
[new TemplateReference('', 'Post', 'index', 'html', 'php'), 'views/Post/index.html.php'],
|
||||
[new TemplateReference('', '', 'index', 'html', 'php'), 'views/index.html.php'],
|
||||
];
|
||||
}
|
||||
}
|
@ -1,119 +0,0 @@
|
||||
<?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\Templating;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Templating\GlobalVariables;
|
||||
use Symfony\Bundle\FrameworkBundle\Templating\TimedPhpEngine;
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
class TimedPhpEngineTest extends TestCase
|
||||
{
|
||||
public function testThatRenderLogsTime()
|
||||
{
|
||||
$container = $this->getContainer();
|
||||
$templateNameParser = $this->getTemplateNameParser();
|
||||
$globalVariables = $this->getGlobalVariables();
|
||||
$loader = $this->getLoader($this->getStorage());
|
||||
|
||||
$stopwatch = $this->getStopwatch();
|
||||
$stopwatchEvent = $this->getStopwatchEvent();
|
||||
|
||||
$stopwatch->expects($this->once())
|
||||
->method('start')
|
||||
->with('template.php (index.php)', 'template')
|
||||
->willReturn($stopwatchEvent);
|
||||
|
||||
$stopwatchEvent->expects($this->once())->method('stop');
|
||||
|
||||
$engine = new TimedPhpEngine($templateNameParser, $container, $loader, $stopwatch, $globalVariables);
|
||||
$engine->render('index.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Container
|
||||
*/
|
||||
private function getContainer()
|
||||
{
|
||||
return $this->getMockBuilder('Symfony\Component\DependencyInjection\Container')->getMock();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Symfony\Component\Templating\TemplateNameParserInterface
|
||||
*/
|
||||
private function getTemplateNameParser()
|
||||
{
|
||||
$templateReference = $this->getMockBuilder('Symfony\Component\Templating\TemplateReferenceInterface')->getMock();
|
||||
$templateNameParser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock();
|
||||
$templateNameParser->expects($this->any())
|
||||
->method('parse')
|
||||
->willReturn($templateReference);
|
||||
|
||||
return $templateNameParser;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return GlobalVariables
|
||||
*/
|
||||
private function getGlobalVariables()
|
||||
{
|
||||
return $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\GlobalVariables')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Symfony\Component\Templating\Storage\StringStorage
|
||||
*/
|
||||
private function getStorage()
|
||||
{
|
||||
return $this->getMockBuilder('Symfony\Component\Templating\Storage\StringStorage')
|
||||
->disableOriginalConstructor()
|
||||
->getMockForAbstractClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Symfony\Component\Templating\Storage\StringStorage $storage
|
||||
*
|
||||
* @return \Symfony\Component\Templating\Loader\Loader
|
||||
*/
|
||||
private function getLoader($storage)
|
||||
{
|
||||
$loader = $this->getMockForAbstractClass('Symfony\Component\Templating\Loader\Loader');
|
||||
$loader->expects($this->once())
|
||||
->method('load')
|
||||
->willReturn($storage);
|
||||
|
||||
return $loader;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Symfony\Component\Stopwatch\StopwatchEvent
|
||||
*/
|
||||
private function getStopwatchEvent()
|
||||
{
|
||||
return $this->getMockBuilder('Symfony\Component\Stopwatch\StopwatchEvent')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Symfony\Component\Stopwatch\Stopwatch
|
||||
*/
|
||||
private function getStopwatch()
|
||||
{
|
||||
return $this->getMockBuilder('Symfony\Component\Stopwatch\Stopwatch')->getMock();
|
||||
}
|
||||
}
|
@ -49,8 +49,7 @@
|
||||
"symfony/serializer": "^4.4|^5.0",
|
||||
"symfony/stopwatch": "^4.4|^5.0",
|
||||
"symfony/translation": "^4.4|^5.0",
|
||||
"symfony/templating": "^4.4|^5.0",
|
||||
"symfony/twig-bundle": "^4.4|^5.0",
|
||||
"symfony/twig-bundle": "^5.0",
|
||||
"symfony/validator": "^4.4|^5.0",
|
||||
"symfony/var-dumper": "^4.4|^5.0",
|
||||
"symfony/workflow": "^4.4|^5.0",
|
||||
@ -77,6 +76,7 @@
|
||||
"symfony/serializer": "<4.4",
|
||||
"symfony/stopwatch": "<4.4",
|
||||
"symfony/translation": "<4.4",
|
||||
"symfony/twig-bundle": "<5.0",
|
||||
"symfony/twig-bridge": "<4.4",
|
||||
"symfony/validator": "<4.4",
|
||||
"symfony/workflow": "<4.4"
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user