Skip to content

Commit e44062a

Browse files
committed
feature symfony#219 Update the way to retrieve the template source (stof)
This PR was merged into the master branch. Discussion ---------- Update the way to retrieve the template source Latest Twig versions allow to get the source from the Twig_Template object itself, making it work with any loader (and without needing the loader). I also switched to private visibility in the CodeExplorerBundle according to the coding standards. Commits ------- 86203de Update the way to retrieve the template source
2 parents 92bd1c9 + 86203de commit e44062a

File tree

3 files changed

+7
-14
lines changed

3 files changed

+7
-14
lines changed

src/CodeExplorerBundle/EventListener/ControllerListener.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@
2828
*/
2929
class ControllerListener
3030
{
31-
/**
32-
* @var SourceCodeExtension
33-
*/
34-
protected $twigExtension;
31+
private $twigExtension;
3532

3633
public function __construct(SourceCodeExtension $twigExtension)
3734
{

src/CodeExplorerBundle/Resources/config/services.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ services:
22
code_explorer.twig.source_code_extension:
33
public: false
44
class: CodeExplorerBundle\Twig\SourceCodeExtension
5-
arguments: [@twig.loader, %kernel.root_dir%]
5+
arguments: [%kernel.root_dir%]
66
tags:
77
- { name: twig.extension }
88

src/CodeExplorerBundle/Twig/SourceCodeExtension.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,12 @@
2222
*/
2323
class SourceCodeExtension extends \Twig_Extension
2424
{
25-
protected $loader;
26-
protected $controller;
27-
protected $kernelRootDir;
25+
private $controller;
26+
private $kernelRootDir;
2827

29-
public function __construct(\Twig_LoaderInterface $loader, $kernelRootDir)
28+
public function __construct($kernelRootDir)
3029
{
3130
$this->kernelRootDir = $kernelRootDir;
32-
$this->loader = $loader;
3331
}
3432

3533
public function setController($controller)
@@ -101,12 +99,10 @@ private function getCallableReflector($callable)
10199

102100
private function getTemplateSource(\Twig_Template $template)
103101
{
104-
$templateName = $template->getTemplateName();
105-
106102
return array(
107-
'file_path' => $this->kernelRootDir.'/Resources/views/'.$templateName,
103+
'file_path' => $this->kernelRootDir.'/Resources/views/'.$template->getTemplateName(),
108104
'starting_line' => 1,
109-
'source_code' => $this->loader->getSource($templateName),
105+
'source_code' => $template->getSource(),
110106
);
111107
}
112108

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy