public function TypeStyleModeration::render in Type Style 8
Renders the field.
Parameters
\Drupal\views\ResultRow $values: The values retrieved from a single row of a view's query result.
Return value
string|\Drupal\Component\Render\MarkupInterface The rendered output. If the output is safe it will be wrapped in an object that implements MarkupInterface. If it is empty or unsafe it will be a string.
Overrides TypeStyle::render
File
- modules/
type_style_moderation/ src/ Plugin/ views/ field/ TypeStyleModeration.php, line 30
Class
- TypeStyleModeration
- A handler to output and arbitrary type style.
Namespace
Drupal\type_style_moderation\Plugin\views\fieldCode
public function render(ResultRow $values) {
$entity = $this
->getEntity($values);
if (isset($entity->moderation_state)) {
$module_handler = \Drupal::moduleHandler();
if (isset($entity->moderation_state->entity) && $module_handler
->moduleExists('workbench_moderation')) {
return type_style_get_style($entity->moderation_state->entity, $this
->getStyleName(), '');
}
elseif (is_string($entity->moderation_state->value) && $module_handler
->moduleExists('content_moderation')) {
$state_id = $entity->moderation_state->value;
return type_style_moderation_get_style($entity, 'states', $state_id, $this
->getStyleName(), '');
}
}
return '';
}