getOption() public method

public getOption ( string $option, mixed $default = null ) : mixed
$option string
$default mixed
return mixed
コード例 #1
0
 /**
  * @param ListBlock                $block
  * @param ElementRendererInterface $htmlRenderer
  * @param bool                     $inTightList
  *
  * @return HtmlElement
  */
 public function render(AbstractBlock $block, ElementRendererInterface $htmlRenderer, $inTightList = false)
 {
     if (!$block instanceof ListBlock) {
         throw new \InvalidArgumentException('Incompatible block type: ' . get_class($block));
     }
     $listData = $block->getListData();
     $tag = $listData->type === ListBlock::TYPE_UNORDERED ? 'ul' : 'ol';
     $attr = $listData->start === null || $listData->start === 1 ? [] : ['start' => (string) $listData->start];
     return new HtmlElement($tag, $attr, $htmlRenderer->getOption('inner_separator', "\n") . $htmlRenderer->renderBlocks($block->getChildren(), $block->isTight()) . $htmlRenderer->getOption('inner_separator', "\n"));
 }
コード例 #2
0
 /**
  * @param BlockQuote               $block
  * @param ElementRendererInterface $htmlRenderer
  * @param bool                     $inTightList
  *
  * @return HtmlElement
  */
 public function render(AbstractBlock $block, ElementRendererInterface $htmlRenderer, $inTightList = false)
 {
     if (!$block instanceof BlockQuote) {
         throw new \InvalidArgumentException('Incompatible block type: ' . get_class($block));
     }
     $filling = $htmlRenderer->renderBlocks($block->getChildren());
     if ($filling === '') {
         return new HtmlElement('blockquote', [], $htmlRenderer->getOption('inner_separator', "\n"));
     }
     return new HtmlElement('blockquote', [], $htmlRenderer->getOption('inner_separator', "\n") . $filling . $htmlRenderer->getOption('inner_separator', "\n"));
 }
コード例 #3
0
 /**
  * @param BlockQuote               $block
  * @param ElementRendererInterface $htmlRenderer
  * @param bool                     $inTightList
  *
  * @return HtmlElement
  */
 public function render(AbstractBlock $block, ElementRendererInterface $htmlRenderer, $inTightList = false)
 {
     if (!$block instanceof BlockQuote) {
         throw new \InvalidArgumentException('Incompatible block type: ' . get_class($block));
     }
     $attrs = [];
     foreach ($block->getData('attributes', []) as $key => $value) {
         $attrs[$key] = $htmlRenderer->escape($value, true);
     }
     $filling = $htmlRenderer->renderBlocks($block->getChildren());
     if ($filling === '') {
         return new HtmlElement('blockquote', $attrs, $htmlRenderer->getOption('inner_separator', "\n"));
     }
     return new HtmlElement('blockquote', $attrs, $htmlRenderer->getOption('inner_separator', "\n") . $filling . $htmlRenderer->getOption('inner_separator', "\n"));
 }
コード例 #4
0
 /**
  * @param ListBlock                $block
  * @param ElementRendererInterface $htmlRenderer
  * @param bool                     $inTightList
  *
  * @return HtmlElement
  */
 public function render(AbstractBlock $block, ElementRendererInterface $htmlRenderer, $inTightList = false)
 {
     if (!$block instanceof ListBlock) {
         throw new \InvalidArgumentException('Incompatible block type: ' . get_class($block));
     }
     $listData = $block->getListData();
     $tag = $listData->type === ListBlock::TYPE_UNORDERED ? 'ul' : 'ol';
     $attrs = [];
     foreach ($block->getData('attributes', []) as $key => $value) {
         $attrs[$key] = $htmlRenderer->escape($value, true);
     }
     if ($listData->start !== null && $listData->start !== 1) {
         $attrs['start'] = (string) $listData->start;
     }
     return new HtmlElement($tag, $attrs, $htmlRenderer->getOption('inner_separator', "\n") . $htmlRenderer->renderBlocks($block->getChildren(), $block->isTight()) . $htmlRenderer->getOption('inner_separator', "\n"));
 }
コード例 #5
0
 /**
  * @param Newline                  $inline
  * @param ElementRendererInterface $htmlRenderer
  *
  * @return HtmlElement|string
  */
 public function render(AbstractInline $inline, ElementRendererInterface $htmlRenderer)
 {
     if (!$inline instanceof Newline) {
         throw new \InvalidArgumentException('Incompatible inline type: ' . get_class($inline));
     }
     if ($inline->getType() === Newline::HARDBREAK) {
         return new HtmlElement('br', [], '', true) . "\n";
     } else {
         return $htmlRenderer->getOption('soft_break', "\n");
     }
 }
コード例 #6
0
 public function render(AbstractBlock $block, ElementRendererInterface $htmlRenderer, $inTightList = false)
 {
     if (!$block instanceof TableRows) {
         throw new \InvalidArgumentException('Incompatible block type: ' . get_class($block));
     }
     if (!$block->hasChildren()) {
         return;
     }
     $attrs = [];
     foreach ($block->getData('attributes', []) as $key => $value) {
         $attrs[$key] = $htmlRenderer->escape($value, true);
     }
     $separator = $htmlRenderer->getOption('inner_separator', "\n");
     return new HtmlElement($block->type, $attrs, $separator . $htmlRenderer->renderBlocks($block->getChildren()) . $separator);
 }