function QueryFactory::deleteConfigKeyStore

Same name and namespace in other branches
  1. 8.9.x core/lib/Drupal/Core/Config/Entity/Query/QueryFactory.php \Drupal\Core\Config\Entity\Query\QueryFactory::deleteConfigKeyStore()
  2. 10 core/lib/Drupal/Core/Config/Entity/Query/QueryFactory.php \Drupal\Core\Config\Entity\Query\QueryFactory::deleteConfigKeyStore()
  3. 11.x core/lib/Drupal/Core/Config/Entity/Query/QueryFactory.php \Drupal\Core\Config\Entity\Query\QueryFactory::deleteConfigKeyStore()

Deletes lookup data.

Parameters

\Drupal\Core\Config\Entity\ConfigEntityTypeInterface $entity_type: The entity type.

\Drupal\Core\Config\Config $config: The configuration object that is being deleted.

1 call to QueryFactory::deleteConfigKeyStore()
QueryFactory::onConfigDelete in core/lib/Drupal/Core/Config/Entity/Query/QueryFactory.php
Removes configuration entity from key store.

File

core/lib/Drupal/Core/Config/Entity/Query/QueryFactory.php, line 125

Class

QueryFactory
Provides a factory for creating entity query objects for the config backend.

Namespace

Drupal\Core\Config\Entity\Query

Code

protected function deleteConfigKeyStore(ConfigEntityTypeInterface $entity_type, Config $config) {
    $config_key_store = $this->getConfigKeyStore($entity_type);
    foreach ($entity_type->getLookupKeys() as $lookup_key) {
        foreach ($this->getKeys($config, $lookup_key, 'getOriginal', $entity_type) as $key) {
            $values = $config_key_store->get($key, []);
            $pos = array_search($config->getName(), $values, TRUE);
            if ($pos !== FALSE) {
                unset($values[$pos]);
            }
            if (empty($values)) {
                $config_key_store->delete($key);
            }
            else {
                $config_key_store->set($key, $values);
            }
        }
    }
}

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