function cms_content_sync_show_usage_operation in CMS Content Sync 2.1.x
Same name and namespace in other branches
- 8 cms_content_sync.module \cms_content_sync_show_usage_operation()
- 2.0.x cms_content_sync.module \cms_content_sync_show_usage_operation()
Parameters
\Drupal\Core\Entity\EntityInterface $entity:
Return value
array
Callback function for the show operation entity action.
1 call to cms_content_sync_show_usage_operation()
File
- ./
cms_content_sync.module, line 1869 - Module file for cms_content_sync.
Code
function cms_content_sync_show_usage_operation(EntityInterface $entity) {
$operations = [];
$flows = PushIntent::getFlowsForEntity($entity, PushIntent::PUSH_ANY);
if (!count($flows)) {
return [];
}
$status_entities = EntityStatus::getInfosForEntity($entity
->getEntityTypeId(), $entity
->uuid());
$is_pushed = FALSE;
foreach ($status_entities as $status_entity) {
$last_push = $status_entity
->get('last_export')->value;
if (!is_null($last_push)) {
$is_pushed = TRUE;
}
}
// Only show the operation for entities which have been pushed.
if ($is_pushed) {
$operations['show_usage'] = [
'title' => t('Show usage'),
'weight' => 151,
'attributes' => [
'class' => [
'use-ajax',
],
'data-dialog-type' => 'modal',
'data-dialog-options' => Json::encode([
'width' => 700,
]),
],
'url' => Url::fromRoute('cms_content_sync.show_usage', [
'entity' => $entity
->id(),
'entity_type' => $entity
->getEntityTypeId(),
]),
];
}
return $operations;
}