Same name in other branches
  1. 2.x src/EntityClone/Content/ContentEntityCloneFormBase.php \Drupal\entity_clone\EntityClone\Content\ContentEntityCloneFormBase::getChildren()

Fetches clonable children from a field.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $referenced_entity: The field item list.

array $discovered_entities: List of all entities already discovered.

Return value

array The list of children.

1 call to ContentEntityCloneFormBase::getChildren()
ContentEntityCloneFormBase::getRecursiveFormElement in src/EntityClone/Content/ContentEntityCloneFormBase.php
Get the recursive form element.

File

src/EntityClone/Content/ContentEntityCloneFormBase.php, line 221

Class

ContentEntityCloneFormBase
Class Content Entity Clone Form Base.

Namespace

Drupal\entity_clone\EntityClone\Content

Code

protected function getChildren(ContentEntityInterface $referenced_entity, array &$discovered_entities) {
    
    /** @var \Drupal\entity_clone\EntityClone\EntityCloneFormInterface $entity_clone_handler */
    if ($this->entityTypeManager
        ->hasHandler($referenced_entity->getEntityTypeId(), 'entity_clone_form')) {
        // Record that we've found this entity.
        $discovered_entities[$referenced_entity->getEntityTypeId()][$referenced_entity->id()] = $referenced_entity;
        $entity_clone_form_handler = $this->entityTypeManager
            ->getHandler($referenced_entity->getEntityTypeId(), 'entity_clone_form');
        return $entity_clone_form_handler->formElement($referenced_entity, FALSE, $discovered_entities);
    }
    return [];
}