public function BootstrapListGroupItemShortcode::process in Bootstrap 3 shortcodes 8
Performs the shortcode processing.
Parameters
array $attributes: Array of attributes.
string $text: The text string to be processed.
string $langcode: The language code of the text to be filtered. Defaults to LANGCODE_NOT_SPECIFIED.
Return value
string The processed text.
Overrides ShortcodeInterface::process
File
- src/
Plugin/ Shortcode/ BootstrapListGroupItemShortcode.php, line 28 - Adds shortcodes for all Bootstrap elements.
Class
- BootstrapListGroupItemShortcode
- @Shortcode( id = "bs_list_group_item", token = "list_group_item", title = @Translation("List Group Item"), description = @Translation("Bootstrap 3 shortcode"), weight = 50 )
Namespace
Drupal\bs_shortcodes\Plugin\ShortcodeCode
public function process(array $attributes, $content, $langcode = Language::LANGCODE_NOT_SPECIFIED) {
$attributes = $this
->getAttributes(array(
'link' => '',
'type' => '',
'active' => '',
'target' => '',
'xclass' => '',
'data' => '',
), $attributes);
$class = 'list-group-item';
$class .= $attributes['type'] ? ' list-group-item-' . $attributes['type'] : '';
$class .= $attributes['active'] != '' ? ' active' : '';
$class .= $attributes['xclass'] ? ' ' . $attributes['xclass'] : '';
$data_props = _bs_shortcodes_parse_data_attributes($attributes['data']);
return sprintf('<%1$s %2$s %3$s class="%4$s"%5$s>%6$s</%1$s>', $attributes['link'] ? 'a' : 'li', $attributes['link'] ? 'href="' . UrlHelper::stripDangerousProtocols($attributes['link']) . '"' : '', $attributes['target'] ? sprintf(' target="%s"', Html::escape($attributes['target'])) : '', Html::escape($class), $data_props ? ' ' . $data_props : '', $content);
}