You are here

public function Activity::preprocess in Open Social 8

Same name and namespace in other branches
  1. 8.9 themes/socialbase/src/Plugin/Preprocess/Activity.php \Drupal\socialbase\Plugin\Preprocess\Activity::preprocess()
  2. 8.2 themes/socialbase/src/Plugin/Preprocess/Activity.php \Drupal\socialbase\Plugin\Preprocess\Activity::preprocess()
  3. 8.3 themes/socialbase/src/Plugin/Preprocess/Activity.php \Drupal\socialbase\Plugin\Preprocess\Activity::preprocess()
  4. 8.4 themes/socialbase/src/Plugin/Preprocess/Activity.php \Drupal\socialbase\Plugin\Preprocess\Activity::preprocess()
  5. 8.5 themes/socialbase/src/Plugin/Preprocess/Activity.php \Drupal\socialbase\Plugin\Preprocess\Activity::preprocess()
  6. 8.6 themes/socialbase/src/Plugin/Preprocess/Activity.php \Drupal\socialbase\Plugin\Preprocess\Activity::preprocess()
  7. 8.7 themes/socialbase/src/Plugin/Preprocess/Activity.php \Drupal\socialbase\Plugin\Preprocess\Activity::preprocess()
  8. 8.8 themes/socialbase/src/Plugin/Preprocess/Activity.php \Drupal\socialbase\Plugin\Preprocess\Activity::preprocess()

Preprocess theme hook variables.

Parameters

array $variables: The variables array, passed by reference (modify in place).

string $hook: The name of the theme hook.

array $info: The theme hook info array.

Overrides PreprocessBase::preprocess

File

themes/socialbase/src/Plugin/Preprocess/Activity.php, line 19

Class

Activity
Pre-processes variables for the "activity" theme hook.

Namespace

Drupal\socialbase\Plugin\Preprocess

Code

public function preprocess(array &$variables, $hook, array $info) {
  parent::preprocess($variables, $hook, $info);

  // Check if the view mode is one of the notification view modes.
  if (in_array($variables['content']['field_activity_output_text']['#view_mode'], [
    'notification',
    'notification_archive',
  ])) {

    // Remove href from output text.
    $variables['content']['field_activity_output_text'][0]['#text'] = strip_tags($variables['content']['field_activity_output_text'][0]['#text']);

    // Remove href from profile image.
    if (!empty($variables['actor'])) {
      if (is_object($variables['actor'])) {
        $variables['actor'] = $variables['actor']
          ->getText();
      }
    }
  }
}