You are here

class EntityHelper in Commerce Core 8.2

Hierarchy

Expanded class hierarchy of EntityHelper

17 files declare their use of EntityHelper
commerce_checkout.module in modules/checkout/commerce_checkout.module
Provides configurable checkout flows.
commerce_product.module in modules/product/commerce_product.module
Defines the Product entity and associated features.
CustomerProfile.php in modules/order/src/Plugin/Commerce/InlineForm/CustomerProfile.php
EntitySelect.php in src/Element/EntitySelect.php
EntitySelectWidgetTest.php in tests/src/Functional/EntitySelectWidgetTest.php

... See full list

File

src/EntityHelper.php, line 5

Namespace

Drupal\commerce
View source
class EntityHelper {

  /**
   * Extracts the IDs of the given entities.
   *
   * @param \Drupal\Core\Entity\EntityInterface[] $entities
   *   The entities.
   *
   * @return array
   *   The entity IDs.
   */
  public static function extractIds(array $entities) : array {
    return array_map(function ($entity) {

      /** @var \Drupal\Core\Entity\EntityInterface $entity */
      return $entity
        ->id();
    }, $entities);
  }

  /**
   * Extracts the labels of the given entities.
   *
   * @param \Drupal\Core\Entity\EntityInterface[] $entities
   *   The entities.
   *
   * @return array
   *   The entity labels.
   */
  public static function extractLabels(array $entities) : array {
    return array_map(function ($entity) {

      /** @var \Drupal\Core\Entity\EntityInterface $entity */
      return $entity
        ->label();
    }, $entities);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EntityHelper::extractIds public static function Extracts the IDs of the given entities.
EntityHelper::extractLabels public static function Extracts the labels of the given entities.