|
|
|
|
@ -12,7 +12,7 @@ use Drupal\views\ViewExecutable;
|
|
|
|
|
* Implements hook_pathauto_pattern_alter(). |
|
|
|
|
*/ |
|
|
|
|
function islandlives_pathauto_pattern_alter(PathautoPatternInterface $pattern, array $context) { |
|
|
|
|
// Only act on the repository_items pattern. |
|
|
|
|
// Nodes: Only act if the pattern has machine name `repository_items`. |
|
|
|
|
if ($pattern->id() == 'repository_items') { |
|
|
|
|
// If node has no PID... |
|
|
|
|
$node = $context['data']['node']; |
|
|
|
|
@ -23,6 +23,17 @@ function islandlives_pathauto_pattern_alter(PathautoPatternInterface $pattern, a
|
|
|
|
|
$pattern->setPattern($new_pattern); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// Taxonomy Terms: Only act if the pattern has machine name `person_vocabulary`. |
|
|
|
|
if ($pattern->id() == 'person_vocabulary') { |
|
|
|
|
// If term has no PID... |
|
|
|
|
$term = $context['data']['taxonomy_term']; |
|
|
|
|
$pid = $term->get('field_pid')->value; |
|
|
|
|
if ($pid == NULL) { |
|
|
|
|
// Replace the PID with the TID in the alias. |
|
|
|
|
$new_pattern = preg_replace('/\[term:field_pid\]/', '[term:tid]', $pattern->getPattern()); |
|
|
|
|
$pattern->setPattern($new_pattern); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|