public function ListTagPlugin::buildElement in Extensible BBCode 8.3
Same name and namespace in other branches
- 4.0.x standard/src/Plugin/XBBCode/ListTagPlugin.php \Drupal\xbbcode_standard\Plugin\XBBCode\ListTagPlugin::buildElement()
Build a render array from the tag.
Parameters
\Drupal\xbbcode\Parser\Tree\TagElementInterface $tag: The tag element in the parse tree.
Return value
array The render array.
Overrides RenderTagPlugin::buildElement
File
- standard/
src/ Plugin/ XBBCode/ ListTagPlugin.php, line 29
Class
- ListTagPlugin
- Renders a list.
Namespace
Drupal\xbbcode_standard\Plugin\XBBCodeCode
public function buildElement(TagElementInterface $tag) : array {
$element['#theme'] = 'item_list';
$style = $tag
->getOption() ?: $tag
->getAttribute('style');
[
$numbered,
$style,
] = static::validateStyle($style);
if ($numbered) {
$element['#list_type'] = 'ol';
}
if ($style) {
$element['#attributes']['style'] = 'list-style-type: ' . $style;
}
foreach (self::splitContent($tag
->getChildren()) as $i => $item) {
$element['#items'][$i] = Markup::create($item
->getContent());
}
return $element;
}