public function DefaultCropHandler::pull in CMS Content Sync 2.1.x
Same name and namespace in other branches
- 8 src/Plugin/cms_content_sync/entity_handler/DefaultCropHandler.php \Drupal\cms_content_sync\Plugin\cms_content_sync\entity_handler\DefaultCropHandler::pull()
- 2.0.x src/Plugin/cms_content_sync/entity_handler/DefaultCropHandler.php \Drupal\cms_content_sync\Plugin\cms_content_sync\entity_handler\DefaultCropHandler::pull()
Pull the remote entity.
Overrides EntityHandlerBase::pull
File
- src/
Plugin/ cms_content_sync/ entity_handler/ DefaultCropHandler.php, line 67
Class
- DefaultCropHandler
- Class DefaultCropHandler, providing a minimalistic implementation for the crop entity type.
Namespace
Drupal\cms_content_sync\Plugin\cms_content_sync\entity_handlerCode
public function pull(PullIntent $intent) {
/** @var FileInterface[] $files */
$files = \Drupal::entityTypeManager()
->getStorage('file')
->loadByProperties([
'uri' => $intent
->getProperty('uri')[0]['value'],
]);
// Unset the entity_id field so that it gets automatically set during
// the entity creation.
if (!count($files)) {
$intent
->overwriteProperty('entity_id', null);
}
else {
/**
* @var \Drupal\file\FileInterface $file
*/
$file = reset($files);
$this
->deleteExistingCrop($intent, $file);
$intent
->overwriteProperty('entity_id', $file
->id());
}
if (!parent::pull($intent)) {
return false;
}
if (!count($files)) {
MissingDependencyManager::saveUnresolvedDependency('file', $intent
->getProperty('uri')[0]['value'], $intent
->getEntity(), $intent
->getReason(), 'entity_id');
}
return true;
}