You are here

protected function PathautoFieldItemList::delegateMethod in Pathauto 8

inheritdoc}

Overrides FieldItemList::delegateMethod

File

src/PathautoFieldItemList.php, line 12

Class

PathautoFieldItemList

Namespace

Drupal\pathauto

Code

protected function delegateMethod($method) {

  // @todo Workaround until this is fixed, see
  //   https://www.drupal.org/project/drupal/issues/2946289.
  $this
    ->ensureComputedValue();

  // Duplicate the logic instead of calling the parent due to the dynamic
  // arguments.
  $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;
}