Skip to content

Commit 5be0baf

Browse files
committed
removed TemplateReferenceInterface::getSignature() (replaced by the existing getLogicalName() which already acts as a unique identifier)
1 parent 5af7c7f commit 5be0baf

File tree

12 files changed

+28
-44
lines changed

12 files changed

+28
-44
lines changed

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplatePathsCacheWarmer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function warmUp($cacheDir)
4646
$templates = array();
4747

4848
foreach ($this->finder->findAllTemplates() as $template) {
49-
$templates[$template->getSignature()] = $this->locator->locate($template);
49+
$templates[$template->getLogicalName()] = $this->locator->locate($template);
5050
}
5151

5252
$this->writeCacheFile($cacheDir.'/templates.php', sprintf('<?php return %s;', var_export($templates, true)));

src/Symfony/Bundle/FrameworkBundle/Templating/Loader/CachedTemplateLocator.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ public function locate($template, $currentPath = null, $first = true)
7272
*/
7373
protected function getCachedTemplatePath(TemplateReferenceInterface $template)
7474
{
75-
$key = $template->getSignature();
75+
$key = $template->getLogicalName();
76+
7677
return isset($this->templates[$key]) ? $this->templates[$key] : null;
7778
}
7879
}

src/Symfony/Bundle/FrameworkBundle/Templating/Loader/TemplateLocator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function locate($template, $currentPath = null, $first = true)
5454
throw new \InvalidArgumentException("The template must be an instance of TemplateReferenceInterface.");
5555
}
5656

57-
$key = $template->getSignature();
57+
$key = $template->getLogicalName();
5858

5959
if (isset($this->cache[$key])) {
6060
return $this->cache[$key];

src/Symfony/Bundle/FrameworkBundle/Templating/TemplateReference.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ class TemplateReference extends BaseTemplateReference
2323
public function __construct($bundle = null, $controller = null, $name = null, $format = null, $engine = null)
2424
{
2525
$this->parameters = array(
26-
'bundle' => $bundle,
27-
'controller' => $controller,
28-
'name' => $name,
29-
'format' => $format,
30-
'engine' => $engine,
26+
'bundle' => $bundle,
27+
'controller' => $controller,
28+
'name' => $name,
29+
'format' => $format,
30+
'engine' => $engine,
3131
);
3232
}
3333

@@ -51,10 +51,6 @@ public function getPath()
5151
*/
5252
public function getLogicalName()
5353
{
54-
$parts = sprintf('%s:%s:', $this->get('bundle'), $this->get('controller'));
55-
$elements = sprintf('%s.%s.%s', $this->get('name'), $this->get('format'), $this->get('engine'));
56-
57-
return $parts . $elements;
54+
return sprintf('%s:%s:%s.%s.%s', $this->get('bundle'), $this->get('controller'), $this->get('name'), $this->get('format'), $this->get('engine'));
5855
}
59-
6056
}

src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function testParse($name, $ref)
4848
{
4949
$template = $this->parser->parse($name);
5050

51-
$this->assertEquals($template->getSignature(), $ref->getSignature());
51+
$this->assertEquals($template->getLogicalName(), $ref->getLogicalName());
5252
$this->assertEquals($template->getLogicalName(), $ref->getLogicalName());
5353
$this->assertEquals($template->getLogicalName(), $name);
5454
}
@@ -96,7 +96,7 @@ public function testParseFromFilename($file, $ref)
9696
if ($ref === false) {
9797
$this->assertFalse($template);
9898
} else {
99-
$this->assertEquals($template->getSignature(), $ref->getSignature());
99+
$this->assertEquals($template->getLogicalName(), $ref->getLogicalName());
100100
}
101101
}
102102

src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ protected function findTemplate($name)
8888
{
8989
$tpl = $this->parser->parse($name);
9090

91-
if (isset($this->cache[$key = $tpl->getSignature()])) {
91+
if (isset($this->cache[$key = $tpl->getLogicalName()])) {
9292
return $this->cache[$key];
9393
}
9494

src/Symfony/Component/Templating/Loader/CacheLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function __construct(LoaderInterface $loader, $dir)
5050
*/
5151
public function load(TemplateReferenceInterface $template)
5252
{
53-
$key = $template->getSignature();
53+
$key = $template->getLogicalName();
5454
$dir = $this->dir.DIRECTORY_SEPARATOR.substr($key, 0, 2);
5555
$file = substr($key, 2).'.tpl';
5656
$path = $dir.DIRECTORY_SEPARATOR.$file;

src/Symfony/Component/Templating/PhpEngine.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ protected function load($name)
488488
{
489489
$template = $this->parser->parse($name);
490490

491-
$key = $template->getSignature();
491+
$key = $template->getLogicalName();
492492
if (isset($this->cache[$key])) {
493493
return $this->cache[$key];
494494
}

src/Symfony/Component/Templating/TemplateReference.php

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ class TemplateReference implements TemplateReferenceInterface
2020
{
2121
protected $parameters;
2222

23-
public function __construct($name = null, $engine = null)
23+
public function __construct($name = null, $engine = null)
2424
{
2525
$this->parameters = array(
26-
'name' => $name,
27-
'engine' => $engine,
26+
'name' => $name,
27+
'engine' => $engine,
2828
);
2929
}
3030

@@ -33,16 +33,6 @@ public function __toString()
3333
return $this->getLogicalName();
3434
}
3535

36-
/**
37-
* Returns the template signature
38-
*
39-
* @return string A UID for the template
40-
*/
41-
public function getSignature()
42-
{
43-
return md5(serialize($this->parameters));
44-
}
45-
4636
/**
4737
* Sets a template parameter.
4838
*
@@ -105,7 +95,9 @@ public function getPath()
10595
}
10696

10797
/**
108-
* Returns the template name
98+
* Returns the "logical" template name.
99+
*
100+
* The template name acts as a unique identifier for the template.
109101
*
110102
* @return string The template name
111103
*/

src/Symfony/Component/Templating/TemplateReferenceInterface.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,6 @@ function set($name, $value);
4848
*/
4949
function get($name);
5050

51-
/**
52-
* Returns the template signature
53-
*
54-
* @return string A UID for the template
55-
*/
56-
function getSignature();
57-
5851
/**
5952
* Returns the path to the template.
6053
*
@@ -65,7 +58,9 @@ function getSignature();
6558
function getPath();
6659

6760
/**
68-
* Returns the template name
61+
* Returns the "logical" template name.
62+
*
63+
* The template name acts as a unique identifier for the template.
6964
*
7065
* @return string The template name
7166
*/

tests/Symfony/Tests/Component/Templating/PhpEngineTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,13 @@ class ProjectTemplateLoader extends Loader
153153
public function setTemplate($name, $content)
154154
{
155155
$template = new TemplateReference($name, 'php');
156-
$this->templates[$template->getSignature()] = $content;
156+
$this->templates[$template->getLogicalName()] = $content;
157157
}
158158

159159
public function load(TemplateReferenceInterface $template)
160160
{
161-
if (isset($this->templates[$template->getSignature()])) {
162-
return new StringStorage($this->templates[$template->getSignature()]);
161+
if (isset($this->templates[$template->getLogicalName()])) {
162+
return new StringStorage($this->templates[$template->getLogicalName()]);
163163
}
164164

165165
return false;

tests/Symfony/Tests/Component/Templating/TemplateNameParserTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function testParse($name, $ref)
3535
{
3636
$template = $this->parser->parse($name);
3737

38-
$this->assertEquals($template->getSignature(), $ref->getSignature());
38+
$this->assertEquals($template->getLogicalName(), $ref->getLogicalName());
3939
$this->assertEquals($template->getLogicalName(), $name);
4040
}
4141

0 commit comments

Comments
 (0)