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); }
/** * {@inheritdoc} */ public function load(ResourceInterface $resource) { $formulae = array(); $failureTemplates = array(); $successTemplates = array(); foreach ($this->activeTheme->getThemes() as $theme) { $this->activeTheme->setName($theme); try { // determine if the template has any errors $this->twig->tokenize($resource->getContent()); // delegate the formula loading to the parent $formulae += parent::load($resource); $successTemplates[(string) $resource] = true; } catch (\Exception $e) { $failureTemplates[(string) $resource] = $e->getMessage(); } } if ($this->logger) { foreach ($failureTemplates as $failureTemplate => $exceptionMessage) { if (isset($successTemplates[$failureTemplate])) { continue; } $this->logger->error(sprintf('The template "%s" contains an error: "%s"', $resource, $exceptionMessage)); } } return $formulae; }
public function load(ResourceInterface $resource) { return parent::load(new TwitalResource($this->twital, $resource)); }