You are here

public function ActivityRow::preRender in Open Social 8

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

Allow the style to do stuff before each row is rendered.

Parameters

$result: The full array of results from the query.

Overrides EntityRow::preRender

File

modules/custom/activity_viewer/src/Plugin/views/row/ActivityRow.php, line 21

Class

ActivityRow
Plugin which performs a activity_view on the resulting object.

Namespace

Drupal\activity_viewer\Plugin\views\row

Code

public function preRender($result) {
  $view_mode = $this->options['view_mode'];
  if ($result) {

    // TODO: Move all this logic to a service.
    // TODO: Change this to use dependency injection.

    /* @var $plugin \Drupal\activity_creator\Plugin\ActivityDestinationManager */
    $destination_plugin_manager = \Drupal::service('plugin.manager.activity_destination.processor');
    foreach ($result as $row) {
      $render_result = [];
      $render_result[] = $row;
      $entity = $row->_entity;
      foreach ($entity->field_activity_destinations as $destination) {

        /* @var $plugin \Drupal\activity_creator\Plugin\ActivityDestinationBase */
        $plugin = $destination_plugin_manager
          ->createInstance($destination->value);
        if ($plugin
          ->isActiveInView($this->view)) {
          $this->options['view_mode'] = $plugin
            ->getViewMode($view_mode, $entity);
        }
      }
      $this
        ->getEntityTranslationRenderer()
        ->preRender($render_result);
    }
  }
  $this->options['view_mode'] = $view_mode;
}