Author: Asmir Mustafic (goetas@gmail.com)
Inheritance: extends Symfony\Component\EventDispatcher\Event
 public function removeCustomNamespaces(SourceEvent $event)
 {
     $template = $event->getTemplate();
     foreach ($this->customNamespaces as $prefix => $ns) {
         $template = preg_replace('#<(.*) xmlns:' . $prefix . '="' . $ns . '"(.*)>#mi', "<\\1\\2>", $template);
     }
     $event->setTemplate($template);
 }
 /**
  *
  * @param SourceEvent $event
  */
 public function removePlaceholder(SourceEvent $event)
 {
     $source = $event->getTemplate();
     $source = preg_replace_callback($this->regexes['placeholder'], function ($matches) {
         return html_entity_decode($matches[2], ENT_COMPAT, 'UTF-8');
     }, $source);
     $event->setTemplate($source);
 }
 /**
  *
  * @param SourceEvent $event
  */
 public function removePlaceholder(SourceEvent $event)
 {
     $source = $event->getTemplate();
     $source = $this->processPlaceholder($source, function ($matches) {
         return html_entity_decode($matches[2], ENT_COMPAT, 'UTF-8');
     });
     $event->setTemplate($source);
 }
示例#4
0
 public function testBaseSetter()
 {
     $template = md5(microtime());
     $ist = new SourceEvent($this->twital, $template);
     $this->assertSame($template, $ist->getTemplate());
     $templateNew = md5(microtime());
     $ist->setTemplate($templateNew);
     $this->assertSame($templateNew, $ist->getTemplate());
 }
 /**
  *
  * @param SourceEvent $event
  */
 public function removePlaceholder(SourceEvent $event)
 {
     $source = $event->getTemplate();
     $placeholders = $this->placeholders;
     $source = $this->processPlaceholder($source, function ($matches) use($placeholders) {
         if (isset($placeholders[$matches[0]])) {
             return $placeholders[$matches[0]];
         } elseif (isset($placeholders[$matches[2]])) {
             return $matches[1] . $placeholders[$matches[2]];
         } else {
             return $matches[0];
         }
     });
     $event->setTemplate($source);
 }
 /**
  *
  * @param SourceEvent $event
  */
 public function removePlaceholder(SourceEvent $event)
 {
     $source = $event->getTemplate();
     $placeholders = $this->placeholders;
     $source = preg_replace_callback($this->regexes['placeholder'], function ($matches) use($placeholders) {
         if (isset($placeholders[$matches[0]])) {
             return $placeholders[$matches[0]];
         } elseif (isset($placeholders[$matches[2]])) {
             return $matches[1] . $placeholders[$matches[2]];
         } else {
             return $matches[0];
         }
     }, $source);
     $event->setTemplate($source);
 }
 public function onPostDump(SourceEvent $event)
 {
     $this->postDumpTemplate = $event->getTemplate();
 }
示例#8
0
 public function fixAttributes(SourceEvent $event)
 {
     $event->setTemplate(preg_replace_callback('/ __attr__="(__a[0-9a-f]+)"/', function ($mch) {
         return '{% for ____ak,____av in ' . $mch[1] . ' if ____av|length>0 %} {{____ak | raw}}="{{ ____av|join(\'\') }}"{% endfor %}';
     }, $event->getTemplate()));
 }