public function __construct(SmartyEngine $engine)
 {
     $this->engine = $engine;
     $this->extension = $this->engine->getExtension('assetic');
     $this->factory = $this->extension->getAssetFactory();
     $plugins = $engine->getPlugins('assetic');
     foreach (array_keys($plugins) as $k) {
         $this->tags[] = $plugins[$k]->getName();
     }
 }
 public function load(ResourceInterface $resource)
 {
     $formulae = array();
     // template source
     $templateSource = $resource->getContent();
     $smarty = $this->engine->getSmarty();
     // ask Smarty which delimiters to use
     $ldelim = $smarty->left_delimiter;
     $rdelim = $smarty->right_delimiter;
     $_ldelim = preg_quote($ldelim);
     $_rdelim = preg_quote($rdelim);
     // template block tags to look for
     $tags = implode('|', $this->tags);
     /**
      * Thanks Rodney!
      *
      * @see https://gist.github.com/483465490f738d1b2b5e
      */
     if (preg_match_all('#' . $_ldelim . '(?<type>' . $tags . ').*?' . $_rdelim . '#s', $templateSource, $matches, PREG_SET_ORDER)) {
         foreach ($matches as $match) {
             if (preg_match_all('#(?<key>[a-zA-Z0-9_]+)\\s*=\\s*(["\']?)(?<value>[^\\2]*?)\\2(\\s|' . $_rdelim . ')#s', $match[0], $_matches, PREG_SET_ORDER)) {
                 $t = array('type' => $match['type'], 'attributes' => array());
                 foreach ($_matches as $_match) {
                     if (empty($_match[2])) {
                         // make eval a little bit safer
                         preg_match('#[^\\w|^\\.]#', $_match['value'], $evalMatches);
                         $_match['value'] = $evalMatches ? null : eval(sprintf('return %s;', $_match['value']));
                     }
                     $t['attributes'][$_match['key']] = $_match['value'];
                 }
                 $formulae += $this->buildFormula($match['type'], $t['attributes']);
             }
         }
     }
     return $formulae;
 }
 public function __construct(Smarty $smarty, ContainerInterface $container, TemplateNameParserInterface $parser, LoaderInterface $loader, array $options, GlobalVariables $globals = null, LoggerInterface $logger = null)
 {
     $this->enrichSmartyHandle($smarty, $container);
     parent::__construct($smarty, $container, $parser, $loader, $options, $globals, $logger);
     $this->setCustomGlobalVariables($container);
 }