function EntityMethod::applyPluralized

Same name in other branches
  1. 11.x core/lib/Drupal/Core/Config/Action/Plugin/ConfigAction/EntityMethod.php \Drupal\Core\Config\Action\Plugin\ConfigAction\EntityMethod::applyPluralized()

Applies the action to entity treating the $values array as multiple calls.

Parameters

\Drupal\Core\Config\Entity\ConfigEntityInterface $entity: The entity to apply the action to.

mixed $values: The values for the action to use.

Return value

\Drupal\Core\Config\Entity\ConfigEntityInterface The unsaved entity with the action applied.

1 call to EntityMethod::applyPluralized()
EntityMethod::apply in core/lib/Drupal/Core/Config/Action/Plugin/ConfigAction/EntityMethod.php
Applies the config action.

File

core/lib/Drupal/Core/Config/Action/Plugin/ConfigAction/EntityMethod.php, line 111

Class

EntityMethod
Makes config entity methods with the ActionMethod attribute into actions.

Namespace

Drupal\Core\Config\Action\Plugin\ConfigAction

Code

private function applyPluralized(ConfigEntityInterface $entity, mixed $values) : ConfigEntityInterface {
    if (!is_array($values)) {
        throw new EntityMethodException(sprintf('The pluralized entity method config action \'%s\' requires an array value in order to call %s::%s() multiple times', $this->pluginId, $entity->getEntityType()
            ->getClass(), $this->method));
    }
    foreach ($values as $value) {
        $entity = $this->applySingle($entity, $value);
    }
    return $entity;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.