StubTemplateNameParser.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper\Fixtures;
  11. use Symfony\Component\Templating\TemplateNameParserInterface;
  12. use Symfony\Component\Templating\TemplateReference;
  13. class StubTemplateNameParser implements TemplateNameParserInterface
  14. {
  15. private $root;
  16. private $rootTheme;
  17. public function __construct($root, $rootTheme)
  18. {
  19. $this->root = $root;
  20. $this->rootTheme = $rootTheme;
  21. }
  22. public function parse($name)
  23. {
  24. list($bundle, $controller, $template) = explode(':', $name, 3);
  25. if ('_' == $template[0]) {
  26. $path = $this->rootTheme.'/Custom/'.$template;
  27. } elseif ('TestBundle' === $bundle) {
  28. $path = $this->rootTheme.'/'.$controller.'/'.$template;
  29. } else {
  30. $path = $this->root.'/'.$controller.'/'.$template;
  31. }
  32. return new TemplateReference($path, 'php');
  33. }
  34. }