$values =
[];
foreach ($this->elements
as $element) { if (empty($fields)) { // @phpstan-ignore-next-line not possible to typehint or docblock the trait
$values[$element->
getUniqueIdentifier()] =
$element->
getCustomFields();
continue;
} // @phpstan-ignore-next-line not possible to typehint or docblock the trait
$values[$element->
getUniqueIdentifier()] =
$element->
getCustomFieldsValues(...
$fields);
} /** @var array<string, mixed> $values */
return $values;
} /**
* Global collector to access the value of a custom field of the collection.
*
* The result is an array with the entity id as key and the value of the custom field as value.
*
* Example:
* ```php
* $collection->getCustomFieldsValue('my_custom_field');
* [
* 'entity-id-1' => 'value',
* 'entity-id-2' => 'value',
* ]
* ```
*
* @return array|mixed[]
*/