ReportContentType.php in Open Social 8.7
Same filename and directory in other branches
- 8.9 modules/social_features/social_content_report/src/Plugin/views/field/ReportContentType.php
- 8.5 modules/social_features/social_content_report/src/Plugin/views/field/ReportContentType.php
- 8.6 modules/social_features/social_content_report/src/Plugin/views/field/ReportContentType.php
- 8.8 modules/social_features/social_content_report/src/Plugin/views/field/ReportContentType.php
- 10.3.x modules/social_features/social_content_report/src/Plugin/views/field/ReportContentType.php
- 10.0.x modules/social_features/social_content_report/src/Plugin/views/field/ReportContentType.php
- 10.1.x modules/social_features/social_content_report/src/Plugin/views/field/ReportContentType.php
- 10.2.x modules/social_features/social_content_report/src/Plugin/views/field/ReportContentType.php
File
modules/social_features/social_content_report/src/Plugin/views/field/ReportContentType.phpView source
<?php
namespace Drupal\social_content_report\Plugin\views\field;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\ResultRow;
/**
* Field handler to present the entity type or bundle type for Nodes.
*
* @ingroup views_field_handlers
*
* @ViewsField("flagging_entity_bundle_type")
*/
class ReportContentType extends FieldPluginBase {
/**
* {@inheritdoc}
*/
public function query() {
}
/**
* {@inheritdoc}
*/
public function render(ResultRow $row) {
/** @var \Drupal\flag\FlaggingInterface $flagging */
$flagging = $this
->getEntity($row);
$reported_entity = $flagging
->getFlaggable();
if ($reported_entity
->getEntityTypeId() === 'node') {
/** @var \Drupal\node\NodeInterface $reported_entity */
return node_get_type_label($reported_entity);
}
else {
return $reported_entity
->getEntityType()
->getLabel();
}
}
}
Classes
Name![]() |
Description |
---|---|
ReportContentType | Field handler to present the entity type or bundle type for Nodes. |