function cms_content_sync_entity_operation in CMS Content Sync 8
Same name and namespace in other branches
- 2.1.x cms_content_sync.module \cms_content_sync_entity_operation()
- 2.0.x cms_content_sync.module \cms_content_sync_entity_operation()
Implements hook_entity_operation().
File
- ./
cms_content_sync.module, line 1877 - Module file for cms_content_sync.
Code
function cms_content_sync_entity_operation(EntityInterface $entity) {
$operations = [];
$entity
->getEntityType();
if ($entity
->getEntityTypeId() == 'cms_content_sync_flow') {
$enabled = !empty(Flow::getAll()[$entity
->id()]);
if ($enabled) {
$operations['export'] = [
'title' => t('Export'),
'weight' => 10,
'url' => Url::fromRoute('entity.cms_content_sync_flow.export', [
'cms_content_sync_flow' => $entity
->id(),
]),
];
$operations['pull_all'] = [
'title' => t('Pull all'),
'weight' => 10,
'url' => Url::fromRoute('entity.cms_content_sync_flow.pull_confirmation', [
'cms_content_sync_flow' => $entity
->id(),
]),
];
$operations['push_all'] = [
'title' => t('Push all'),
'weight' => 10,
'url' => Url::fromRoute('entity.cms_content_sync_flow.push_confirmation', [
'cms_content_sync_flow' => $entity
->id(),
]),
];
}
$set_status_title = $enabled ? t('Set inactive') : t('Set active');
$operations['set_status'] = [
'title' => $set_status_title,
'weight' => 10,
'url' => Url::fromRoute('entity.cms_content_sync_flow.set_status', [
'cms_content_sync_flow' => $entity
->id(),
]),
];
}
elseif ($entity
->getEntityTypeId() == 'cms_content_sync_pool') {
$operations['export'] = [
'title' => t('Export'),
'weight' => 10,
'url' => Url::fromRoute('entity.cms_content_sync_pool.export', [
'cms_content_sync_pool' => $entity
->id(),
]),
];
$operations['reset_status'] = [
'title' => t('Reset status entities'),
'weight' => 10,
'url' => Url::fromRoute('entity.cms_content_sync_pool.reset_status_entity_confirmation', [
'cms_content_sync_pool' => $entity
->id(),
]),
];
}
return $operations;
}