/** * @param CertificationManager $certificationManager */ public function addCertificationTemplateDir(CertificationManager $certificationManager) { if (!is_dir($this->baseDir)) { throw new \RuntimeException('certification-data folder not found: did you install the certifications ?'); } foreach (array_keys($certificationManager->getCertifications()) as $certificationName) { $this->loader->addPath($this->baseDir . '/' . $certificationName, $certificationName); } }
public function testTwigSoftErrorIfTemplateDoesNotExist() { $parser = $this->getMockBuilder('Symfony\\Component\\Templating\\TemplateNameParserInterface')->getMock(); $locator = $this->getMockBuilder('Symfony\\Component\\Config\\FileLocatorInterface')->getMock(); $loader = new FilesystemLoader($locator, $parser); $loader->addPath(__DIR__ . '/../DependencyInjection/Fixtures/Resources/views'); $method = new \ReflectionMethod('Symfony\\Bundle\\TwigBundle\\Loader\\FilesystemLoader', 'findTemplate'); $method->setAccessible(true); $this->assertFalse($method->invoke($loader, 'name.format.engine', false)); }
public function testGetSource() { $parser = $this->getMock('Symfony\\Component\\Templating\\TemplateNameParserInterface'); $locator = $this->getMock('Symfony\\Component\\Config\\FileLocatorInterface'); $locator->expects($this->once())->method('locate')->will($this->returnValue(__DIR__ . '/../DependencyInjection/Fixtures/Resources/views/layout.html.twig')); $loader = new FilesystemLoader($locator, $parser); $loader->addPath(__DIR__ . '/../DependencyInjection/Fixtures/Resources/views', 'namespace'); // Twig-style $this->assertEquals("This is a layout\n", $loader->getSource('@namespace/layout.html.twig')); // Symfony-style $this->assertEquals("This is a layout\n", $loader->getSource('TwigBundle::layout.html.twig')); }
/** * __construct * * Extension constructor. * * @access public * @param FilesystemLoader $loader */ public function __construct(FilesystemLoader $loader) { $loader->addPath($this->getTemplateDirectory(), 'Pomm'); }