private function applyAttributes(AbstractBlock $block)
 {
     $previous = null;
     $prepend = null;
     foreach ($block->getChildren() as $key => $child) {
         if ($child instanceof Attributes) {
             if ($child->isPrepend()) {
                 $prepend = $child;
             } elseif ($child->isAppend()) {
                 $previous->data['attributes'] = AttributesUtils::merge($previous ?: $block, $child->getAttributes());
             }
             $block->removeChild($child);
         } else {
             if (isset($prepend)) {
                 $child->data['attributes'] = AttributesUtils::merge($child, $prepend->getAttributes());
             }
             $prepend = null;
             $this->applyAttributes($child);
             $previous = $child;
         }
     }
     if (isset($prepend)) {
         $block->data['attributes'] = AttributesUtils::merge($block, $prepend->getAttributes());
     }
     return $block;
 }
Example #2
0
 private function processInlines(ContextInterface $context, AbstractBlock $block)
 {
     if ($block instanceof AbstractInlineContainer) {
         $cursor = new Cursor(trim($block->getStringContent()));
         $block->setInlines($this->inlineParserEngine->parse($context, $cursor));
     }
     foreach ($block->getChildren() as $child) {
         $this->processInlines($context, $child);
     }
 }