Phrozn\Site\View\Twig::setInputFile PHP Method

setInputFile() public method

Set input file path. Overriden to update processor options.
public setInputFile ( $path ) : Phrozn\Site\View
return Phrozn\Site\View
    public function setInputFile($path)
    {
        parent::setInputFile($path);
        $processors = $this->getProcessors();
        if (count($processors)) {
            $options = array('phr_template_filename' => basename($path), 'phr_template_dir' => dirname($path));
            $processor = array_pop($processors);
            $processor->setConfig($options);
        }
        return $this;
    }

Usage Example

Example #1
0
 public function testEntriesPaths()
 {
     $view = new View\Twig();
     $view->setInputFile('/var/www/phrozn-test/entries/some-entry.twig')->setOutputDir('/var/www/output');
     $path = new OutputPath\Entry($view);
     $this->assertSame('/var/www/output/some-entry.html', $path->get());
     $view->setInputFile('/var/www/phrozn-test/entries/sub/folder/some-entry.twig')->setOutputDir('/var/www/output');
     $path->setView($view);
     $this->assertSame('/var/www/output/sub/folder/some-entry.html', $path->get());
     $view->setInputFile('/var/www/phrozn-test/sub/folder/some-entry.twig')->setOutputDir('/var/www/output');
     $path->setView($view);
     $this->assertSame('/var/www/output/some-entry.html', $path->get());
 }