Assetic\Extension\Twig\TwigFormulaLoader::load PHP Method

load() public method

public load ( Assetic\Factory\Resource\ResourceInterface $resource )
$resource Assetic\Factory\Resource\ResourceInterface
    public function load(ResourceInterface $resource)
    {
        try {
            $tokens = $this->twig->tokenize(new \Twig_Source($resource->getContent(), (string) $resource));
            $nodes = $this->twig->parse($tokens);
        } catch (\Exception $e) {
            if ($this->logger) {
                $this->logger->error(sprintf('The template "%s" contains an error: %s', $resource, $e->getMessage()));
            }
            return array();
        }
        return $this->loadNode($nodes);
    }

Usage Example

コード例 #1
0
 public function testEmbeddedTemplate()
 {
     $expected = array('image' => array(array('images/foo.png'), array(), array('name' => 'image', 'debug' => true, 'vars' => array(), 'output' => 'images/foo.png', 'combine' => false)));
     $resource = $this->getMock('Assetic\\Factory\\Resource\\ResourceInterface');
     $resource->expects($this->once())->method('getContent')->will($this->returnValue(file_get_contents(__DIR__ . '/templates/embed.twig')));
     $formulae = $this->loader->load($resource);
     $this->assertEquals($expected, $formulae);
 }
All Usage Examples Of Assetic\Extension\Twig\TwigFormulaLoader::load