You are here

protected function ActivityFactory::processArguments in Open Social 8.7

Same name and namespace in other branches
  1. 8.9 modules/custom/activity_creator/src/ActivityFactory.php \Drupal\activity_creator\ActivityFactory::processArguments()
  2. 8 modules/custom/activity_creator/src/ActivityFactory.php \Drupal\activity_creator\ActivityFactory::processArguments()
  3. 8.2 modules/custom/activity_creator/src/ActivityFactory.php \Drupal\activity_creator\ActivityFactory::processArguments()
  4. 8.3 modules/custom/activity_creator/src/ActivityFactory.php \Drupal\activity_creator\ActivityFactory::processArguments()
  5. 8.4 modules/custom/activity_creator/src/ActivityFactory.php \Drupal\activity_creator\ActivityFactory::processArguments()
  6. 8.5 modules/custom/activity_creator/src/ActivityFactory.php \Drupal\activity_creator\ActivityFactory::processArguments()
  7. 8.6 modules/custom/activity_creator/src/ActivityFactory.php \Drupal\activity_creator\ActivityFactory::processArguments()
  8. 8.8 modules/custom/activity_creator/src/ActivityFactory.php \Drupal\activity_creator\ActivityFactory::processArguments()
  9. 10.3.x modules/custom/activity_creator/src/ActivityFactory.php \Drupal\activity_creator\ActivityFactory::processArguments()
  10. 10.0.x modules/custom/activity_creator/src/ActivityFactory.php \Drupal\activity_creator\ActivityFactory::processArguments()
  11. 10.1.x modules/custom/activity_creator/src/ActivityFactory.php \Drupal\activity_creator\ActivityFactory::processArguments()
  12. 10.2.x modules/custom/activity_creator/src/ActivityFactory.php \Drupal\activity_creator\ActivityFactory::processArguments()

Process the message given the arguments saved with it.

Parameters

array $arguments: Array with the arguments.

array $output: Array with the templated text saved in the message template.

\Drupal\message\Entity\Message $message: Message object.

Return value

array The templated text, with the placeholders replaced with the actual value, if there are indeed arguments.

1 call to ActivityFactory::processArguments()
ActivityFactory::getMessageText in modules/custom/activity_creator/src/ActivityFactory.php
Get message text.

File

modules/custom/activity_creator/src/ActivityFactory.php, line 455

Class

ActivityFactory
Class ActivityFactory to create Activity items based on ActivityLogs.

Namespace

Drupal\activity_creator

Code

protected function processArguments(array $arguments, array $output, Message $message) {

  // Check if we have arguments saved along with the message.
  if (empty($arguments)) {
    return $output;
  }
  foreach ($arguments as $key => $value) {
    if (is_array($value) && !empty($value['callback']) && is_callable($value['callback'])) {

      // A replacement via callback function.
      $value += [
        'pass message' => FALSE,
      ];
      if ($value['pass message']) {

        // Pass the message object as-well.
        $value['arguments']['message'] = $message;
      }
      $arguments[$key] = call_user_func_array($value['callback'], $value['arguments']);
    }
  }
  foreach ($output as $key => $value) {
    $output[$key] = new FormattableMarkup($value, $arguments);
  }
  return $output;
}