public static function MessageArgumentsWorker::getArguments in Message UI 8
Get hard coded arguments.
Parameters
string $template: The message template.
bool $count: Determine weather to the count the arguments or return a list of them.
Return value
int|array The number of the arguments.
1 call to MessageArgumentsWorker::getArguments()
- message_ui_entity_update in ./
message_ui.module - Implements hook_entity_update().
File
- src/
Plugin/ QueueWorker/ MessageArgumentsWorker.php, line 64
Class
- MessageArgumentsWorker
- Queue worker plugin instance to update the message arguments.
Namespace
Drupal\message_ui\Plugin\QueueWorkerCode
public static function getArguments($template, $count = FALSE) {
/* @var $message_template MessageTemplate */
if (!($message_template = MessageTemplate::load($template))) {
return [];
}
if (!($output = $message_template
->getText())) {
return [];
}
$text = array_map(function (Markup $markup) {
return (string) $markup;
}, $output);
$text = implode("\n", $text);
preg_match_all('/[@|%|\\!]\\{([a-z0-9:_\\-]+?)\\}/i', $text, $matches);
return $count ? count($matches[0]) : $matches[0];
}