FieldItemList::delegateMethod

protected FieldItemList::delegateMethod($method)

Calls a method on each FieldItem.

Any argument passed will be forwarded to the invoked method.

Parameters

string $method: The name of the method to be invoked.

Return value

array An array of results keyed by delta.

File

core/lib/Drupal/Core/Field/FieldItemList.php, line 238

Class

FieldItemList
Represents an entity field; that is, a list of field item objects.

Namespace

Drupal\Core\Field

Code

protected function delegateMethod($method) {
  $result = [];
  $args = array_slice(func_get_args(), 1);
  foreach ($this->list as $delta => $item) {
    // call_user_func_array() is way slower than a direct call so we avoid
    // using it if have no parameters.
    $result[$delta] = $args ? call_user_func_array([$item, $method], $args) : $item->{$method}();
  }
  return $result;
}
doc_Drupal
2016-10-29 09:11:53
Comments
Leave a Comment

Please login to continue.