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;
}
doc_Drupal
2016-10-29 08:44:13
Comments
Leave a Comment

Please login to continue.