function AliasStorage::delete

Deletes a URL alias.

The default implementation performs case-insensitive matching on the 'source' and 'alias' strings.

Parameters

array $conditions: An array of criteria.

Overrides AliasStorageInterface::delete

File

core/lib/Drupal/Core/Path/AliasStorage.php, line 162

Class

AliasStorage
Provides a class for CRUD operations on path aliases.

Namespace

Drupal\Core\Path

Code

public function delete($conditions) {
  $storage = $this->getPathAliasEntityStorage();
  $query = $storage->getQuery();
  // API functions should be able to access all entities regardless of access
  // restrictions. Those need to happen on a higher level.
  $query->accessCheck(FALSE);
  foreach ($conditions as $field => $value) {
    if ($field === 'source') {
      $field = 'path';
    }
    elseif ($field === 'pid') {
      $field = 'id';
    }
    $query->condition($field, $value, '=');
  }
  $result = $query->execute();
  $storage->delete($storage->loadMultiple($result));
}

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