class EntityHelper in Commerce Core 8.2
Hierarchy
- class \Drupal\commerce\EntityHelper
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
File
- src/
EntityHelper.php, line 5
Namespace
Drupal\commerceView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EntityHelper:: |
public static | function | Extracts the IDs of the given entities. | |
EntityHelper:: |
public static | function | Extracts the labels of the given entities. |