/** * TemplatesManager * * @return \Tlumx\View\TemplatesManager */ public function getTemplatesManager() { if (!$this->templatesManager) { $this->templatesManager = new TemplatesManager(); $templatesPaths = $this->getConfig('templates_paths', []); if ($templatesPaths) { $this->templatesManager->setTemplatePaths($templatesPaths); } $templates = $this->getConfig('templates', []); if ($templates) { $this->templatesManager->setTemplateMap($templates); } } return $this->templatesManager; }
public function testTemplatesPath() { $tm = new TemplatesManager(); $this->assertEquals([], $tm->getTemplatePaths()); $tm->setTemplatePaths(['a' => 'a-path', 'b' => 'b-path']); $this->assertEquals(['a' => 'a-path' . DIRECTORY_SEPARATOR, 'b' => 'b-path' . DIRECTORY_SEPARATOR], $tm->getTemplatePaths()); $tm->addTemplatePath('c', __DIR__); $this->assertEquals(['a' => 'a-path' . DIRECTORY_SEPARATOR, 'b' => 'b-path' . DIRECTORY_SEPARATOR, 'c' => __DIR__ . DIRECTORY_SEPARATOR], $tm->getTemplatePaths()); $this->assertTrue($tm->hasTemplatePath('a')); $this->assertTrue($tm->hasTemplatePath('b')); $this->assertTrue($tm->hasTemplatePath('c')); $this->assertFalse($tm->hasTemplatePath('d')); $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR, $tm->getTemplatePath('c')); $tm->clearTemplatePaths(); $this->assertFalse($tm->hasTemplatePath('a')); $this->assertFalse($tm->hasTemplatePath('b')); $this->assertFalse($tm->hasTemplatePath('c')); $this->assertEquals([], $tm->getTemplatePaths()); }