You are here

public function AliasStorageHelper::deleteEntityPathAll in Pathauto 8

Delete an entity URL alias and any of its sub-paths.

This function also checks to see if the default entity URI is different from the current entity URI and will delete any of the default aliases.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: An entity object.

string $default_uri: The optional default uri path for the entity.

Overrides AliasStorageHelperInterface::deleteEntityPathAll

File

src/AliasStorageHelper.php, line 201

Class

AliasStorageHelper
Provides helper methods for accessing alias storage.

Namespace

Drupal\pathauto

Code

public function deleteEntityPathAll(EntityInterface $entity, $default_uri = NULL) {
  $this
    ->deleteBySourcePrefix('/' . $entity
    ->toUrl('canonical')
    ->getInternalPath());
  if (isset($default_uri) && $entity
    ->toUrl('canonical')
    ->toString() != $default_uri) {
    $this
      ->deleteBySourcePrefix($default_uri);
  }
}