Same name in other branches
- 2.x src/EntityClone/Config/ConfigWithFieldEntityClone.php \Drupal\entity_clone\EntityClone\Config\ConfigWithFieldEntityClone::cloneDisplays()
Clone all fields. Each field re-use existing field storage.
Paramètres
string $type: The type of display (view or form).
string $entity_id: The base entity ID.
string $cloned_entity_id: The cloned entity ID.
array $view_displays: All view available display for this type.
string $bundle_of: The bundle of the cloned entity.
1 call to ConfigWithFieldEntityClone::cloneDisplays()
- ConfigWithFieldEntityClone::cloneEntity dans src/
EntityClone/ Config/ ConfigWithFieldEntityClone.php - Clone an entity.
Fichier
-
src/
EntityClone/ Config/ ConfigWithFieldEntityClone.php, line 87
Classe
- ConfigWithFieldEntityClone
- Class Content Entity Clone Base.
Namespace
Drupal\entity_clone\EntityClone\ConfigCode
protected function cloneDisplays($type, $entity_id, $cloned_entity_id, array $view_displays, $bundle_of) {
foreach ($view_displays as $view_display_id => $view_display) {
/** @var \Drupal\Core\Entity\Display\EntityDisplayInterface $display */
$display = $this->entityTypeManager
->getStorage('entity_' . $type . '_display')
->load($bundle_of . '.' . $entity_id . '.' . $view_display_id);
if ($display) {
/** @var \Drupal\entity_clone\EntityClone\EntityCloneInterface $view_display_clone_handler */
$view_display_clone_handler = $this->entityTypeManager
->getHandler($this->entityTypeManager
->getDefinition($display->getEntityTypeId())
->id(), 'entity_clone');
$view_display_properties = [
'id' => $bundle_of . '.' . $cloned_entity_id . '.' . $view_display_id,
];
$cloned_view_display = $display->createDuplicate();
$cloned_view_display->set('bundle', $cloned_entity_id);
$view_display_clone_handler->cloneEntity($display, $cloned_view_display, $view_display_properties);
}
}
}