function cms_content_sync_entity_operation in CMS Content Sync 2.1.x
Same name and namespace in other branches
- 8 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 1912 - 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 to Sync Core'),
'weight' => 10,
'url' => Url::fromRoute('entity.cms_content_sync_flow.export', [
'cms_content_sync_flow' => $entity
->id(),
]),
];
if ($entity->type !== Flow::TYPE_PUSH) {
$operations['pull_all'] = [
'title' => t('Pull all content'),
'weight' => 10,
'url' => $entity->variant === Flow::VARIANT_SIMPLE ? Url::fromRoute('cms_content_sync.syndication', [], [
'query' => [
'flow' => $entity
->id(),
'startNew' => 'true',
],
]) : Url::fromRoute('entity.cms_content_sync_flow.pull_confirmation', [
'cms_content_sync_flow' => $entity
->id(),
]),
];
}
if ($entity->type !== Flow::TYPE_PULL) {
$operations['push_all'] = [
'title' => t('Push all content'),
'weight' => 10,
'url' => $entity->variant === Flow::VARIANT_SIMPLE ? Url::fromRoute('cms_content_sync.syndication', [], [
'query' => [
'flow' => $entity
->id(),
'startNew' => 'true',
],
]) : 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;
}