protected function EntityHandlerBase::createNew 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::createNew()
- 2.0.x src/Plugin/EntityHandlerBase.php \Drupal\cms_content_sync\Plugin\EntityHandlerBase::createNew()
Return value
\Drupal\Core\Entity\EntityInterface
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
2 calls to EntityHandlerBase::createNew()
- DefaultFieldCollectionItemHandler::createNew in src/
Plugin/ cms_content_sync/ entity_handler/ DefaultFieldCollectionItemHandler.php - EntityHandlerBase::pull in src/
Plugin/ EntityHandlerBase.php - Pull the remote entity.
1 method overrides EntityHandlerBase::createNew()
- DefaultFieldCollectionItemHandler::createNew in src/
Plugin/ cms_content_sync/ entity_handler/ DefaultFieldCollectionItemHandler.php
File
- src/
Plugin/ EntityHandlerBase.php, line 430
Class
- EntityHandlerBase
- Common base class for entity handler plugins.
Namespace
Drupal\cms_content_sync\PluginCode
protected function createNew(PullIntent $intent) {
$entity_type = \Drupal::entityTypeManager()
->getDefinition($intent
->getEntityType());
$base_data = [];
if (EntityHandlerPluginManager::isEntityTypeConfiguration($intent
->getEntityType())) {
$base_data['id'] = $intent
->getId();
}
if ($this
->hasLabelProperty()) {
$base_data[$entity_type
->getKey('label')] = $intent
->getOperation()
->getName();
}
// Required as field collections share the same property for label and bundle.
$base_data[$entity_type
->getKey('bundle')] = $intent
->getBundle();
$base_data[$entity_type
->getKey('uuid')] = $intent
->getUuid();
if ($entity_type
->getKey('langcode')) {
$base_data[$entity_type
->getKey('langcode')] = $intent
->getProperty($entity_type
->getKey('langcode'));
}
$storage = \Drupal::entityTypeManager()
->getStorage($intent
->getEntityType());
return $storage
->create($base_data);
}