Changeset 32459
- Timestamp:
- 04/08/11 17:30:04 (2 years ago)
- Files:
-
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/Templating/Loader/TemplateLocator.php (modified) (1 diff)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateReference.php (modified) (2 diffs)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php (modified) (2 diffs)
- branches/2.0/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/Templating/DelegatingEngine.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/Templating/PhpEngine.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/Templating/TemplateReference.php (modified) (6 diffs)
- branches/2.0/src/Symfony/Component/Templating/TemplateReferenceInterface.php (modified) (1 diff)
- branches/2.0/tests/Symfony/Tests/Component/Templating/TemplateNameParserTest.php (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/2.0/src/Symfony/Bundle/FrameworkBundle/Templating/Loader/TemplateLocator.php
r32457 r32459 61 61 return $this->cache[$key] = $this->locator->locate($template->getPath(), $this->path); 62 62 } catch (\InvalidArgumentException $e) { 63 throw new \InvalidArgumentException(sprintf('Unable to find template "%s" in "%s".', $template->get Path(), $this->path), 0, $e);63 throw new \InvalidArgumentException(sprintf('Unable to find template "%s" in "%s".', $template->getLogicalName(), $this->path), 0, $e); 64 64 } 65 65 } branches/2.0/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateReference.php
r32184 r32459 36 36 * - as a path when the template is not part of a bundle 37 37 * - as a resource when the template is part of a bundle 38 * 38 * 39 39 * @return string A path to the template or a resource 40 40 */ … … 47 47 } 48 48 49 /** 50 * {@inheritdoc} 51 */ 52 public function getLogicalName() 53 { 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; 58 } 59 49 60 } branches/2.0/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php
r32439 r32459 42 42 43 43 $this->assertEquals($template->getSignature(), $ref->getSignature()); 44 $this->assertEquals($template->getLogicalName(), $ref->getLogicalName()); 45 $this->assertEquals($template->getLogicalName(), $name); 44 46 } 45 47 … … 83 85 { 84 86 $template = $this->parser->parseFromFilename($file); 85 87 86 88 if ($ref === false) { 87 89 $this->assertFalse($template); branches/2.0/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php
r32445 r32459 95 95 96 96 if (false === $file || null === $file) { 97 throw new \Twig_Error_Loader(sprintf('Unable to find t he template %s', json_encode($name)), -1, null, $previous);97 throw new \Twig_Error_Loader(sprintf('Unable to find template "%s".', $tpl->getLogicalName()), -1, null, $previous); 98 98 } 99 99 branches/2.0/src/Symfony/Component/Templating/DelegatingEngine.php
r32184 r32459 107 107 } 108 108 109 throw new \RuntimeException(sprintf('No engine is able to work with the "%s" template.', $name));109 throw new \RuntimeException(sprintf('No engine is able to work with the %s template.', json_encode($name))); 110 110 } 111 111 } branches/2.0/src/Symfony/Component/Templating/PhpEngine.php
r32184 r32459 83 83 // render 84 84 if (false === $content = $this->evaluate($storage, $parameters)) { 85 throw new \RuntimeException(sprintf('The template "%s" cannot be rendered.', json_encode($name)));85 throw new \RuntimeException(sprintf('The template "%s" cannot be rendered.', $this->parser->parse($name)->getLogicalName())); 86 86 } 87 87 branches/2.0/src/Symfony/Component/Templating/TemplateReference.php
r32184 r32459 31 31 public function __toString() 32 32 { 33 return json_encode($this->parameters);33 return $this->getLogicalName(); 34 34 } 35 35 36 36 /** 37 * {@inheritDoc} 37 * Returns the template signature 38 * 39 * @return string A UID for the template 38 40 */ 39 41 public function getSignature() … … 43 45 44 46 /** 45 * {@inheritDoc} 47 * Sets a template parameter. 48 * 49 * @param string $name The parameter name 50 * @param string $value The parameter value 51 * 52 * @return TemplateReferenceInterface The TemplateReferenceInterface instance 53 * 54 * @throws \InvalidArgumentException if the parameter is not defined 46 55 */ 47 56 public function set($name, $value) … … 57 66 58 67 /** 59 * {@inheritDoc} 68 * Gets a template parameter. 69 * 70 * @param string $name The parameter name 71 * 72 * @return string The parameter value 73 * 74 * @throws \InvalidArgumentException if the parameter is not defined 60 75 */ 61 76 public function get($name) … … 69 84 70 85 /** 71 * {@inheritDoc} 86 * Gets the template parameters. 87 * 88 * @return array An array of parameters 72 89 */ 73 90 public function all() … … 77 94 78 95 /** 79 * {@inheritDoc} 96 * Returns the path to the template. 97 * 98 * By default, it just returns the template name. 99 * 100 * @return string A path to the template or a resource 80 101 */ 81 102 public function getPath() … … 83 104 return $this->parameters['name']; 84 105 } 106 107 /** 108 * Returns the template name 109 * 110 * @return string The template name 111 */ 112 public function getLogicalName() 113 { 114 return $this->parameters['name']; 115 } 85 116 } branches/2.0/src/Symfony/Component/Templating/TemplateReferenceInterface.php
r32184 r32459 64 64 */ 65 65 function getPath(); 66 67 /** 68 * Returns the template name 69 * 70 * @return string The template name 71 */ 72 function getLogicalName(); 66 73 }