ActivityRow.php in Open Social 8.4
Same filename and directory in other branches
- 8.9 modules/custom/activity_viewer/src/Plugin/views/row/ActivityRow.php
- 8 modules/custom/activity_viewer/src/Plugin/views/row/ActivityRow.php
- 8.2 modules/custom/activity_viewer/src/Plugin/views/row/ActivityRow.php
- 8.3 modules/custom/activity_viewer/src/Plugin/views/row/ActivityRow.php
- 8.5 modules/custom/activity_viewer/src/Plugin/views/row/ActivityRow.php
- 8.6 modules/custom/activity_viewer/src/Plugin/views/row/ActivityRow.php
- 8.7 modules/custom/activity_viewer/src/Plugin/views/row/ActivityRow.php
- 8.8 modules/custom/activity_viewer/src/Plugin/views/row/ActivityRow.php
- 10.3.x modules/custom/activity_viewer/src/Plugin/views/row/ActivityRow.php
- 10.0.x modules/custom/activity_viewer/src/Plugin/views/row/ActivityRow.php
- 10.1.x modules/custom/activity_viewer/src/Plugin/views/row/ActivityRow.php
- 10.2.x modules/custom/activity_viewer/src/Plugin/views/row/ActivityRow.php
Namespace
Drupal\activity_viewer\Plugin\views\rowFile
modules/custom/activity_viewer/src/Plugin/views/row/ActivityRow.phpView source
<?php
namespace Drupal\activity_viewer\Plugin\views\row;
use Drupal\views\Plugin\views\row\EntityRow;
/**
* Plugin which performs a activity_view on the resulting object.
*
* @ingroup views_row_plugins
*
* @ViewsRow(
* id = "entity:activity",
* )
*/
class ActivityRow extends EntityRow {
/**
* {@inheritdoc}
*/
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;
}
}
Classes
Name | Description |
---|---|
ActivityRow | Plugin which performs a activity_view on the resulting object. |