You are here

public static function EntityBrowserElement::processEntityIds in Entity Browser 8

Same name and namespace in other branches
  1. 8.2 src/Element/EntityBrowserElement.php \Drupal\entity_browser\Element\EntityBrowserElement::processEntityIds()

Processes entity IDs and gets array of loaded entities.

Parameters

array|string $ids: Processes entity IDs as they are returned from the entity browser. They are in [entity_type_id]:[entity_id] form. Array of IDs or a space-delimited string is supported.

Return value

\Drupal\Core\Entity\EntityInterface[] Array of entity objects.

6 calls to EntityBrowserElement::processEntityIds()
EntityBrowserElement::processEntityId in src/Element/EntityBrowserElement.php
Processes entity IDs and gets array of loaded entities.
EntityBrowserElement::valueCallback in src/Element/EntityBrowserElement.php
Determines how user input is mapped to an element's #value property.
EntityReferenceBrowserWidget::formElementEntities in src/Plugin/Field/FieldWidget/EntityReferenceBrowserWidget.php
Determines the entities used for the form element.
EntityReferenceBrowserWidget::getEntitiesByTargetId in src/Plugin/Field/FieldWidget/EntityReferenceBrowserWidget.php
Get selected elements from target_id element on form.
entity_browser_entity_form_reference_form_submit in modules/entity_form/entity_browser_entity_form.module
Submits the form for adding existing entities.

... See full list

File

src/Element/EntityBrowserElement.php, line 250

Class

EntityBrowserElement
Provides an Entity Browser form element.

Namespace

Drupal\entity_browser\Element

Code

public static function processEntityIds($ids) {
  if (!is_array($ids)) {
    $ids = array_filter(explode(' ', $ids));
  }
  return array_map(function ($item) {
    list($entity_type, $entity_id) = explode(':', $item);
    $entity = \Drupal::entityTypeManager()
      ->getStorage($entity_type)
      ->load($entity_id);
    return \Drupal::service('entity.repository')
      ->getTranslationFromContext($entity);
  }, $ids);
}