function ConfigEntityUpdater::doOne

Same name in other branches
  1. 9 core/lib/Drupal/Core/Config/Entity/ConfigEntityUpdater.php \Drupal\Core\Config\Entity\ConfigEntityUpdater::doOne()
  2. 11.x core/lib/Drupal/Core/Config/Entity/ConfigEntityUpdater.php \Drupal\Core\Config\Entity\ConfigEntityUpdater::doOne()

Apply the callback an entity and save it if the callback makes changes.

Parameters

\Drupal\Core\Config\Entity\ConfigEntityInterface $entity: The entity to potentially update.

callable $callback: The callback to apply.

1 call to ConfigEntityUpdater::doOne()
ConfigEntityUpdater::update in core/lib/Drupal/Core/Config/Entity/ConfigEntityUpdater.php
Updates configuration entities as part of a Drupal update.

File

core/lib/Drupal/Core/Config/Entity/ConfigEntityUpdater.php, line 189

Class

ConfigEntityUpdater
A utility class to make updating configuration entities simple.

Namespace

Drupal\Core\Config\Entity

Code

protected function doOne(ConfigEntityInterface $entity, callable $callback) {
    if (call_user_func($callback, $entity)) {
        $entity->trustData();
        $entity->save();
    }
}

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