You are here

private static function Paths::getAliasObject in Hook Update Deploy Tools 8

Same name and namespace in other branches
  1. 7 src/Paths.php \HookUpdateDeployTools\Paths::getAliasObject()

Build and get the $alias object to be passed around.

Parameters

string $original_alias: The original alias.

string $new_alias: The new alias to set.

string $language: Drupal language value.

Return value

\stdClass An object containing original and new alias properties.

1 call to Paths::getAliasObject()
Paths::modifyAlias in src/Paths.php
Change the value of an alias.

File

src/Paths.php, line 177

Class

Paths
Public methods for altering aliases.

Namespace

HookUpdateDeployTools

Code

private static function getAliasObject($original_alias, $new_alias, $language) {
  $alias = new \stdClass();
  Check::canUse('pathauto');
  $alias->original = new \stdClass();
  $alias->new = new \stdClass();
  $alias->original->alias = $original_alias;

  // Bring in the pathauto.inc file.
  module_load_include('inc', 'pathauto', 'pathauto');
  Check::canCall('pathauto_clean_alias');
  $alias->new->alias = pathauto_clean_alias($new_alias);
  $alias->original->language = $language;
  $alias->new->language = $language;

  // Use the old alias to get the source (drupal system path).
  $alias->original->source = drupal_lookup_path('source', $original_alias, $language);

  // Build the new path only to see if it already exists.
  $alias->new->source = drupal_lookup_path('source', $new_alias, $language);
  return $alias;
}