Exemplo n.º 1
0
 function it_can_inject_non_php_content(NodeInterface $child, BlockInterface $parent)
 {
     $child->compile()->willReturn($content = '{{ ignoredTag1 }}{{ ignoredTag2 }}{{ ignoredTag3 }}');
     $child->isPhp()->willReturn(false);
     $child->getExtractionId()->willReturn('__content__');
     $child->validate()->willReturn(true);
     $parent->getCurrentContent()->willReturn('<?php foreach($items as $item): ?>__content__<?php endforeach; ?>');
     $parent->setCurrentContent('<?php foreach($items as $item): ?>{{ ignoredTag1 }}{{ ignoredTag2 }}{{ ignoredTag3 }}<?php endforeach; ?>')->shouldBeCalled();
     $this->injectContent($child, $parent);
 }
Exemplo n.º 2
0
 /**
  * Create child nodes
  *
  * @return NodeInterface
  */
 public function createChildNodes(NodeInterface $node)
 {
     /** @var NodeInterface $nodeType */
     foreach ($this->getNodeTypes($this->getNodeGroup()) as $nodeType) {
         foreach ($nodeType->getMatches($node->getCurrentContent()) as $offset => $match) {
             $this->createChildNode($node, $nodeType, $match, $offset);
         }
     }
     return $this;
 }
Exemplo n.º 3
0
 /**
  * Set children
  *
  * @param NodeInterface $node
  * @internal param array $children
  * @return NodeInterface
  */
 public function addChild(NodeInterface $node)
 {
     $node->setParentId($this->getId());
     if (!in_array($node->getId(), $this->children)) {
         $this->children[] = $node->getId();
     }
     return $this;
 }
Exemplo n.º 4
0
 /**
  * Inject content
  */
 public function injectContent(NodeInterface $child, NodeInterface $parent)
 {
     if ($child instanceof BlockInterface or !$child->isPhp()) {
         $source = $child->compile();
     } else {
         $source = $this->php($child->compile());
     }
     if (!($validate = $child->validate())) {
         $this->getLexicon()->getFoundation()->getNodeFactory()->getCollection()->forget($child->getId());
     }
     $content = preg_replace($this->search($child->getExtractionId()), $source, $parent->getCurrentContent(), self::LIMIT);
     $parent->setCurrentContent($content);
 }