" tags:
- *
- * use Symfony\Component\Form\Extension\Templating\TemplatingExtension;
- *
- * $formFactory = Forms::createFormFactoryBuilder()
- * ->addExtension(new TemplatingExtension($engine, null, [
- * 'FrameworkBundle:Form',
- * ]))
- * ->getFormFactory();
- *
- * The next example shows how to include the "
" layout:
- *
- * use Symfony\Component\Form\Extension\Templating\TemplatingExtension;
- *
- * $formFactory = Forms::createFormFactoryBuilder()
- * ->addExtension(new TemplatingExtension($engine, null, [
- * 'FrameworkBundle:Form',
- * 'FrameworkBundle:FormTable',
- * ]))
- * ->getFormFactory();
- *
* @author Bernhard Schussek
*/
final class Forms
diff --git a/src/Symfony/Component/Form/composer.json b/src/Symfony/Component/Form/composer.json
index fd39d77edc..bb3d43077e 100644
--- a/src/Symfony/Component/Form/composer.json
+++ b/src/Symfony/Component/Form/composer.json
@@ -48,8 +48,7 @@
"suggest": {
"symfony/validator": "For form validation.",
"symfony/security-csrf": "For protecting forms against CSRF attacks.",
- "symfony/twig-bridge": "For templating with Twig.",
- "symfony/framework-bundle": "For templating with PHP."
+ "symfony/twig-bridge": "For templating with Twig."
},
"autoload": {
"psr-4": { "Symfony\\Component\\Form\\": "" },
diff --git a/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php b/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php
index 7b8e761922..9a700a9b11 100644
--- a/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php
+++ b/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php
@@ -59,6 +59,10 @@ class HIncludeFragmentRenderer extends RoutableFragmentRenderer
throw new \InvalidArgumentException('The hinclude rendering strategy needs an instance of Twig\Environment or Symfony\Component\Templating\EngineInterface');
}
+ if ($templating instanceof EngineInterface) {
+ @trigger_error(sprintf('Using a "%s" instance for "%s" is deprecated since version 4.3; use a \Twig\Environment instance instead.', EngineInterface::class, __CLASS__), E_USER_DEPRECATED);
+ }
+
$this->templating = $templating;
}
diff --git a/src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php b/src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php
index 6125d95ff4..f80f5f811a 100644
--- a/src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php
@@ -16,6 +16,8 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Controller\ControllerReference;
use Symfony\Component\HttpKernel\Fragment\HIncludeFragmentRenderer;
use Symfony\Component\HttpKernel\UriSigner;
+use Twig\Environment;
+use Twig\Loader\ArrayLoader;
class HIncludeFragmentRendererTest extends TestCase
{
@@ -74,7 +76,17 @@ class HIncludeFragmentRendererTest extends TestCase
$this->assertEquals('default', $strategy->render('/foo', Request::create('/'), ['default' => 'default', 'id' => 'bar', 'attributes' => ['p1' => 'v1', 'p2' => 'v2']])->getContent());
}
- public function testRenderWithDefaultText()
+ public function testRenderWithTwigAndDefaultText()
+ {
+ $twig = new Environment($loader = new ArrayLoader());
+ $strategy = new HIncludeFragmentRenderer($twig);
+ $this->assertEquals('loading...', $strategy->render('/foo', Request::create('/'), ['default' => 'loading...'])->getContent());
+ }
+
+ /**
+ * @group legacy
+ */
+ public function testRenderWithDefaultTextLegacy()
{
$engine = $this->getMockBuilder('Symfony\\Component\\Templating\\EngineInterface')->getMock();
$engine->expects($this->once())
@@ -86,17 +98,4 @@ class HIncludeFragmentRendererTest extends TestCase
$strategy = new HIncludeFragmentRenderer($engine);
$this->assertEquals('default', $strategy->render('/foo', Request::create('/'), ['default' => 'default'])->getContent());
}
-
- public function testRenderWithEngineAndDefaultText()
- {
- $engine = $this->getMockBuilder('Symfony\\Component\\Templating\\EngineInterface')->getMock();
- $engine->expects($this->once())
- ->method('exists')
- ->with('loading...')
- ->willThrowException(new \RuntimeException());
-
- // only default
- $strategy = new HIncludeFragmentRenderer($engine);
- $this->assertEquals('loading...', $strategy->render('/foo', Request::create('/'), ['default' => 'loading...'])->getContent());
- }
}
diff --git a/src/Symfony/Component/HttpKernel/composer.json b/src/Symfony/Component/HttpKernel/composer.json
index 7cae1e7484..998f14f6e6 100644
--- a/src/Symfony/Component/HttpKernel/composer.json
+++ b/src/Symfony/Component/HttpKernel/composer.json
@@ -39,7 +39,8 @@
"symfony/templating": "~3.4|~4.0",
"symfony/translation": "~4.2",
"symfony/var-dumper": "^4.1.1",
- "psr/cache": "~1.0"
+ "psr/cache": "~1.0",
+ "twig/twig": "^1.34|^2.4"
},
"provide": {
"psr/log-implementation": "1.0"