protected function FilterInlineSms::theme in SMS Framework 8
Same name and namespace in other branches
- 2.x modules/sms_sendtophone/src/Plugin/Filter/FilterInlineSms.php \Drupal\sms_sendtophone\Plugin\Filter\FilterInlineSms::theme()
- 2.1.x modules/sms_sendtophone/src/Plugin/Filter/FilterInlineSms.php \Drupal\sms_sendtophone\Plugin\Filter\FilterInlineSms::theme()
Themes the message using a text link.
1 call to FilterInlineSms::theme()
- FilterInlineSms::process in modules/
sms_sendtophone/ src/ Plugin/ Filter/ FilterInlineSms.php - Performs the filter processing.
File
- modules/
sms_sendtophone/ src/ Plugin/ Filter/ FilterInlineSms.php, line 100
Class
- FilterInlineSms
- Provides a filter to align elements.
Namespace
Drupal\sms_sendtophone\Plugin\FilterCode
protected function theme($text, $type = 'icon') {
switch ($type) {
case 'text':
$markup = '(' . $this->settings['display_text'] . ')';
break;
case 'icon':
default:
if (!isset($this->settings["default_icon"]) || $this->settings["default_icon"] == 1) {
$icon_path = drupal_get_path('module', 'sms_sendtophone') . '/sms-send.gif';
}
else {
$icon_path = $this->settings["custom_icon_path"];
}
$title = $this
->t('Send the highlighted text via SMS.');
$icon_path = base_path() . $icon_path;
// @todo: Figure out a better way to render the icon.
$markup = Markup::create("<img src='{$icon_path}' alt='{$this->settings["display_text"]}' title='{$title}'/>");
break;
}
$options = [
'attributes' => [
'title' => t('Send the highlighted text via SMS.'),
'class' => 'sms-sendtophone',
],
'query' => [
'text' => urlencode($text),
],
'html' => TRUE,
];
$link = [
'#type' => 'link',
'#prefix' => '<span class="sms-sendtophone-inline">' . $text . '</span> ',
'#title' => $markup,
'#url' => Url::fromRoute('sms_sendtophone.page', [
'type' => 'inline',
], $options),
];
return $this
->renderer()
->renderPlain($link);
}