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 authored and swirtSJW committed Jan 18, 2024
1 parent cbe3762 commit 1802869
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1933,10 +1933,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 1802869

Please sign in to comment.