public function EntityHandlerBase::pull in CMS Content Sync 8
Same name and namespace in other branches
- 2.1.x src/Plugin/EntityHandlerBase.php \Drupal\cms_content_sync\Plugin\EntityHandlerBase::pull()
- 2.0.x src/Plugin/EntityHandlerBase.php \Drupal\cms_content_sync\Plugin\EntityHandlerBase::pull()
Pull the remote entity.
Overrides EntityHandlerInterface::pull
3 calls to EntityHandlerBase::pull()
- DefaultConfigEntityHandler::pull in src/
Plugin/ cms_content_sync/ entity_handler/ DefaultConfigEntityHandler.php - Pull the remote entity.
- DefaultCropHandler::pull in src/
Plugin/ cms_content_sync/ entity_handler/ DefaultCropHandler.php - Pull the remote entity.
- DefaultMenuLinkContentHandler::pull in src/
Plugin/ cms_content_sync/ entity_handler/ DefaultMenuLinkContentHandler.php - Pull the remote entity.
4 methods override EntityHandlerBase::pull()
- DefaultConfigEntityHandler::pull in src/
Plugin/ cms_content_sync/ entity_handler/ DefaultConfigEntityHandler.php - Pull the remote entity.
- DefaultCropHandler::pull in src/
Plugin/ cms_content_sync/ entity_handler/ DefaultCropHandler.php - Pull the remote entity.
- DefaultMenuLinkContentHandler::pull in src/
Plugin/ cms_content_sync/ entity_handler/ DefaultMenuLinkContentHandler.php - Pull the remote entity.
- DefaultTaxonomyHandler::pull in src/
Plugin/ cms_content_sync/ entity_handler/ DefaultTaxonomyHandler.php - Pull the remote entity.
File
- src/
Plugin/ EntityHandlerBase.php, line 168
Class
- EntityHandlerBase
- Common base class for entity handler plugins.
Namespace
Drupal\cms_content_sync\PluginCode
public function pull(PullIntent $intent) {
$action = $intent
->getAction();
if ($this
->ignorePull($intent)) {
return false;
}
/**
* @var \Drupal\Core\Entity\EntityInterface $entity
*/
$entity = $intent
->getEntity();
if (SyncIntent::ACTION_DELETE == $action) {
if ($entity) {
return $this
->deleteEntity($entity);
}
// Already done means success.
if ($intent
->getEntityStatus()
->isDeleted()) {
return true;
}
return false;
}
if ($entity) {
if ($bundle_entity_type = $entity
->getEntityType()
->getBundleEntityType()) {
$bundle_entity_type = \Drupal::entityTypeManager()
->getStorage($bundle_entity_type)
->load($entity
->bundle());
if ($bundle_entity_type instanceof RevisionableEntityBundleInterface && $bundle_entity_type
->shouldCreateNewRevision() || 'field_collection' == $bundle_entity_type
->getEntityTypeId()) {
$entity
->setNewRevision(true);
}
}
}
else {
$entity = $this
->createNew($intent);
if (!$entity) {
throw new SyncException(SyncException::CODE_ENTITY_API_FAILURE);
}
$intent
->setEntity($entity);
}
if ($entity instanceof FieldableEntityInterface && !$this
->setEntityValues($intent)) {
return false;
}
// Allow other modules to extend the EntityHandlerBase pull.
// Dispatch ExtendEntityPull.
\Drupal::service('event_dispatcher')
->dispatch(BeforeEntityPull::EVENT_NAME, new BeforeEntityPull($entity, $intent));
return true;
}