public function RenderedFlags::render in CMS Content Sync 8
Same name and namespace in other branches
- 2.1.x modules/cms_content_sync_views/src/Plugin/views/field/RenderedFlags.php \Drupal\cms_content_sync_views\Plugin\views\field\RenderedFlags::render()
- 2.0.x modules/cms_content_sync_views/src/Plugin/views/field/RenderedFlags.php \Drupal\cms_content_sync_views\Plugin\views\field\RenderedFlags::render()
inheritdoc}
Parameters
\Drupal\views\ResultRow $values:
Return value
\Drupal\Component\Render\MarkupInterface|TranslatableMarkup|ViewsRenderPipelineMarkup|string
Overrides FieldPluginBase::render
File
- modules/
cms_content_sync_views/ src/ Plugin/ views/ field/ RenderedFlags.php, line 123
Class
- RenderedFlags
- Views Field handler to check if a entity is pulled.
Namespace
Drupal\cms_content_sync_views\Plugin\views\fieldCode
public function render(ResultRow $values) {
/**
* @var \Drupal\cms_content_sync\Entity\EntityStatus $entity
*/
$entity = $values->_entity;
$flags = [
'push_failed' => $entity
->didPushFail(),
'push_failed_soft' => $entity
->didPushFail(NULL, TRUE),
'pull_failed' => $entity
->didPullFail(),
'pull_failed_soft' => $entity
->didPullFail(NULL, TRUE),
'last_push_reset' => $entity
->wasLastPushReset(),
'last_pull_reset' => $entity
->wasLastPullReset(),
'is_source_entity' => $entity
->isSourceEntity(),
'edit_override' => $entity
->isOverriddenLocally(),
'is_deleted' => $entity
->isDeleted(),
'pulled_embedded' => $entity
->wasPulledEmbedded(),
'pushed_embedded' => $entity
->wasPushedEmbedded(),
];
$messages = [];
if ($flags['push_failed']) {
$details = $entity
->getData(EntityStatus::DATA_PUSH_FAILURE);
$messages['push_failed'] = $this
->renderError('push_failed', $details);
}
if ($flags['push_failed_soft']) {
$details = $entity
->getData(EntityStatus::DATA_PUSH_FAILURE);
$messages['push_failed_soft'] = $this
->renderError('push_failed', $details);
}
if ($flags['pull_failed']) {
$details = $entity
->getData(EntityStatus::DATA_PULL_FAILURE);
$messages['pull_failed'] = $this
->renderError('pull_failed', $details);
}
if ($flags['pull_failed_soft']) {
$details = $entity
->getData(EntityStatus::DATA_PULL_FAILURE);
$messages['pull_failed_soft'] = $this
->renderError('pull_failed', $details);
}
foreach ($flags as $name => $set) {
if (!$set || isset($messages[$name])) {
continue;
}
$messages[$name] = $this
->t(self::FLAG_DESCRIPTION[$name]);
}
$renderable = [
'#theme' => 'rendered_flags',
'#messages' => $messages,
'#cache' => [
'max-age' => 0,
],
];
$rendered = \Drupal::service('renderer')
->render($renderable);
return $rendered;
}