protected function SyncCoreEntityListResource::getItem in CMS Content Sync 2.0.x
Same name and namespace in other branches
- 2.1.x src/Plugin/rest/resource/SyncCoreEntityListResource.php \Drupal\cms_content_sync\Plugin\rest\resource\SyncCoreEntityListResource::getItem()
1 call to SyncCoreEntityListResource::getItem()
- SyncCoreEntityListResource::get in src/
Plugin/ rest/ resource/ SyncCoreEntityListResource.php
File
- src/
Plugin/ rest/ resource/ SyncCoreEntityListResource.php, line 310
Class
- SyncCoreEntityListResource
- Provides entity interfaces for Content Sync, allowing Sync Core v2 to list entities.
Namespace
Drupal\cms_content_sync\Plugin\rest\resourceCode
protected function getItem(Flow $flow, ?object $entity, array $statuses) {
$item = new RemoteEntitySummary();
$pools = [];
$last_push = null;
foreach ($statuses as $status) {
$pools[] = $status
->getPool()
->id();
if (!$last_push || $status
->getLastPush() > $last_push
->getLastPush()) {
$last_push = $status;
}
}
$item
->setPoolMachineNames($pools);
$item
->setIsSource(empty($statuses) || (bool) $last_push);
if ($entity) {
$item
->setEntityTypeNamespaceMachineName($entity
->getEntityTypeId());
$item
->setEntityTypeMachineName($entity
->bundle());
$item
->setEntityTypeVersion(Flow::getEntityTypeVersion($entity
->getEntityTypeId(), $entity
->bundle()));
$item
->setRemoteUuid($entity
->uuid());
if (EntityHandlerPluginManager::isEntityTypeConfiguration($entity
->getEntityTypeId())) {
$item
->setRemoteUniqueId($entity
->id());
}
$item
->setLanguage($entity
->language()
->getId());
$item
->setName($entity
->label());
$item
->setIsDeleted(false);
$config = $flow
->getEntityTypeConfig($entity
->getEntityTypeId(), $entity
->bundle());
$handler = $flow
->getEntityTypeHandler($config);
$item
->setViewUrl($handler
->getViewUrl($entity));
//$item->setReferenceDetails();
}
else {
$item
->setEntityTypeNamespaceMachineName($last_push
->getEntityTypeName());
$item
->setEntityTypeVersion($last_push
->getEntityTypeVersion());
$item
->setRemoteUuid($last_push
->getUuid());
$item
->setIsDeleted($last_push
->isDeleted());
}
return $item;
}