protected FieldItemList::delegateMethod($method)
Calls a method on each FieldItem.
Any argument passed will be forwarded to the invoked method.
string $method: The name of the method to be invoked.
array An array of results keyed by delta.
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; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Field!FieldItemList.php/function/FieldItemList::delegateMethod/8.1.x