public function AliasStorage::delete

public AliasStorage::delete($conditions)

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 157

Class

AliasStorage
Provides a class for CRUD operations on path aliases.

Namespace

Drupal\Core\Path

Code

public function delete($conditions) {
  $path = $this->load($conditions);
  $query = $this->connection->delete(static::TABLE);
  foreach ($conditions as $field => $value) {
    if ($field == 'source' || $field == 'alias') {
      // Use LIKE for case-insensitive matching.
      $query->condition($field, $this->connection->escapeLike($value), 'LIKE');
    }
    else {
      $query->condition($field, $value);
    }
  }
  try {
    $deleted = $query->execute();
  }
  catch (\Exception $e) {
    $this->catchException($e);
    $deleted = FALSE;
  }
  // @todo Switch to using an event for this instead of a hook.
  $this->moduleHandler->invokeAll('path_delete', array($path));
  Cache::invalidateTags(['route_match']);
  return $deleted;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Path!AliasStorage.php/function/AliasStorage::delete/8.1.x