Skip to content

Commit

Permalink
VACMS-14623: Adds a comment about the preg_match pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
omahane committed Jan 11, 2024
1 parent 94a615a commit 18a5ba0
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1945,10 +1945,10 @@ function _va_gov_backend_disable_autopath_alias(FieldableEntityInterface $entity
$toggled_on_this_save = $current_use_alias_pattern && !$original_use_alias_pattern;
$active_entity = \Drupal::entityTypeManager()->getStorage('node')->load($entity->id());
$published_previously = ($active_entity instanceof NodeInterface) ? $active_entity->isPublished() : FALSE;
// Determine whether path alias is set.
$path = '/node/' . (int) $active_entity->nid->value;
$langcode = \Drupal::languageManager()->getCurrentLanguage()->getId();
$path_alias = \Drupal::service('path_alias.manager')->getAliasByPath($path, $langcode);
// If the path_alias is the node path, alias is not set.
$path_alias_set = (bool) preg_match('/\/node\/\d+/', $path_alias) ? FALSE : TRUE;

if ($path_alias_set && $published_previously && !$toggled_on_this_save) {
Expand Down

0 comments on commit 18a5ba0

Please sign in to comment.