function EntityMethod::apply

Same name and namespace in other branches
  1. 10 core/lib/Drupal/Core/Config/Action/Plugin/ConfigAction/EntityMethod.php \Drupal\Core\Config\Action\Plugin\ConfigAction\EntityMethod::apply()

Applies the config action.

Parameters

string $configName: The name of the config to apply the action to.

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

Overrides ConfigActionPluginInterface::apply

File

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

Class

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

Namespace

Drupal\Core\Config\Action\Plugin\ConfigAction

Code

public function apply(string $configName, mixed $value) : void {
  /** @var \Drupal\Core\Config\Entity\ConfigEntityInterface|null $entity */
  $entity = $this->configManager
    ->loadConfigEntityByName($configName);
  if ($this->exists
    ->returnEarly($configName, $entity)) {
    return;
  }
  $entity = $this->pluralized ? $this->applyPluralized($entity, $value) : $this->applySingle($entity, $value);
  $entity->save();
}

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