Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 887c0e9

Browse filesBrowse files
committed
moved EngineInterface::stream() to a new StreamingEngineInterface to keep BC with 2.0
1 parent 473741b commit 887c0e9
Copy full SHA for 887c0e9

File tree

6 files changed

+43
-18
lines changed
Filter options

6 files changed

+43
-18
lines changed

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ function($v, Reference $ref) use ($container) {
389389
$this->addClassesToCompile(array(
390390
'Symfony\\Bundle\\FrameworkBundle\\Templating\\GlobalVariables',
391391
'Symfony\\Bundle\\FrameworkBundle\\Templating\\EngineInterface',
392+
'Symfony\\Bundle\\FrameworkBundle\\Templating\\StreamingEngineInterface',
392393
'Symfony\\Component\\Templating\\TemplateNameParserInterface',
393394
'Symfony\\Component\\Templating\\TemplateNameParser',
394395
'Symfony\\Component\\Templating\\EngineInterface',

‎src/Symfony/Bundle/TwigBundle/TwigEngine.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/TwigEngine.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@
1717
use Symfony\Component\Templating\TemplateNameParserInterface;
1818
use Symfony\Component\HttpFoundation\Response;
1919
use Symfony\Component\Config\FileLocatorInterface;
20+
use Symfony\Component\Templating\StreamingEngineInterface;
2021

2122
/**
2223
* This engine knows how to render Twig templates.
2324
*
2425
* @author Fabien Potencier <fabien@symfony.com>
2526
*/
26-
class TwigEngine implements EngineInterface
27+
class TwigEngine implements EngineInterface, StreamingEngineInterface
2728
{
2829
protected $environment;
2930
protected $parser;

‎src/Symfony/Component/Templating/DelegatingEngine.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Templating/DelegatingEngine.php
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*
1919
* @api
2020
*/
21-
class DelegatingEngine implements EngineInterface
21+
class DelegatingEngine implements EngineInterface, StreamingEngineInterface
2222
{
2323
protected $engines;
2424

@@ -67,7 +67,12 @@ public function render($name, array $parameters = array())
6767
*/
6868
public function stream($name, array $parameters = array())
6969
{
70-
$this->getEngine($name)->stream($name, $parameters);
70+
$engine = $this->getEngine($name);
71+
if (!$engine instanceof StreamingEngineInterface) {
72+
throw new \LogicException(sprintf('Template "%s" cannot be streamed as the engine supporting it does not implement StreamingEngineInterface.', $name));
73+
}
74+
75+
$engine->stream($name, $parameters);
7176
}
7277

7378
/**

‎src/Symfony/Component/Templating/EngineInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Templating/EngineInterface.php
-14Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,6 @@ interface EngineInterface
4646
*/
4747
function render($name, array $parameters = array());
4848

49-
/**
50-
* Streams a template.
51-
*
52-
* The implementation should output the content directly to the client.
53-
*
54-
* @param mixed $name A template name or a TemplateReferenceInterface instance
55-
* @param array $parameters An array of parameters to pass to the template
56-
*
57-
* @throws \RuntimeException if the template cannot be rendered
58-
*
59-
* @api
60-
*/
61-
function stream($name, array $parameters = array());
62-
6349
/**
6450
* Returns true if the template exists.
6551
*

‎src/Symfony/Component/Templating/PhpEngine.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Templating/PhpEngine.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*
2929
* @api
3030
*/
31-
class PhpEngine implements EngineInterface, \ArrayAccess
31+
class PhpEngine implements EngineInterface, StreamingEngineInterface, \ArrayAccess
3232
{
3333
protected $loader;
3434
protected $current;
+32Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Templating;
13+
14+
/**
15+
* StreamingEngineInterface provides a method that knows how to stream a template.
16+
*
17+
* @author Fabien Potencier <fabien@symfony.com>
18+
*/
19+
interface StreamingEngineInterface
20+
{
21+
/**
22+
* Streams a template.
23+
*
24+
* The implementation should output the content directly to the client.
25+
*
26+
* @param mixed $name A template name or a TemplateReferenceInterface instance
27+
* @param array $parameters An array of parameters to pass to the template
28+
*
29+
* @throws \RuntimeException if the template cannot be rendered
30+
*/
31+
function stream($name, array $parameters = array());
32+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.