diff --git a/src/EventSubscriber/LinkHeaderSubscriber.php b/src/EventSubscriber/LinkHeaderSubscriber.php index 4edf7da4..107d3725 100644 --- a/src/EventSubscriber/LinkHeaderSubscriber.php +++ b/src/EventSubscriber/LinkHeaderSubscriber.php @@ -214,8 +214,8 @@ abstract class LinkHeaderSubscriber implements EventSubscriberInterface { // it becomes the taxonomy term's local uri. if ($referencedEntity->getEntityTypeId() == 'taxonomy_term') { $rel = "tag"; - if ($referencedEntity->hasField('field_external_uri')) { - $external_uri = $referencedEntity->get('field_external_uri')->getValue(); + if ($referencedEntity->hasField(IslandoraUtils::EXTERNAL_URI_FIELD)) { + $external_uri = $referencedEntity->get(IslandoraUtils::EXTERNAL_URI_FIELD)->getValue(); if (!empty($external_uri) && isset($external_uri[0]['uri'])) { $entity_url = $external_uri[0]['uri']; } diff --git a/src/EventSubscriber/NodeLinkHeaderSubscriber.php b/src/EventSubscriber/NodeLinkHeaderSubscriber.php index 443ce86f..92eac804 100644 --- a/src/EventSubscriber/NodeLinkHeaderSubscriber.php +++ b/src/EventSubscriber/NodeLinkHeaderSubscriber.php @@ -3,6 +3,7 @@ namespace Drupal\islandora\EventSubscriber; use Drupal\node\NodeInterface; +use Drupal\islandora\IslandoraUtils; use Symfony\Component\HttpKernel\Event\FilterResponseEvent; use Symfony\Component\EventDispatcher\EventSubscriberInterface; @@ -50,8 +51,8 @@ class NodeLinkHeaderSubscriber extends LinkHeaderSubscriber implements EventSubs foreach ($this->utils->getMedia($node) as $media) { $url = $this->utils->getEntityUrl($media); foreach ($media->referencedEntities() as $term) { - if ($term->getEntityTypeId() == 'taxonomy_term' && $term->hasField('field_external_uri')) { - $field = $term->get('field_external_uri'); + if ($term->getEntityTypeId() == 'taxonomy_term' && $term->hasField(IslandoraUtils::EXTERNAL_URI_FIELD)) { + $field = $term->get(IslandoraUtils::EXTERNAL_URI_FIELD); if (!$field->isEmpty()) { $link = $field->first()->getValue(); $uri = $link['uri']; diff --git a/src/Plugin/ContextReaction/JsonldTypeAlterReaction.php b/src/Plugin/ContextReaction/JsonldTypeAlterReaction.php index 56c68cd5..ae4bc55a 100644 --- a/src/Plugin/ContextReaction/JsonldTypeAlterReaction.php +++ b/src/Plugin/ContextReaction/JsonldTypeAlterReaction.php @@ -6,6 +6,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\islandora\ContextReaction\NormalizerAlterReaction; use Drupal\jsonld\Normalizer\NormalizerBase; +use Drupal\islandora\IslandoraUtils; /** * Alter JSON-LD Type context reaction. @@ -46,13 +47,14 @@ class JsonldTypeAlterReaction extends NormalizerAlterReaction { if ($elem['@id'] === $this->getSubjectUrl($entity)) { foreach ($entity->get($config['source_field'])->getValue() as $type) { // If the configured field is using an entity reference, - // we will see if it uses the core config's field_external_uri. + // we will see if it uses the core config's + // IslandoraUtils::EXTERNAL_URI_FIELD. if (array_key_exists('target_id', $type)) { $target_type = $entity->get($config['source_field'])->getFieldDefinition()->getSetting('target_type'); $referenced_entity = \Drupal::entityTypeManager()->getStorage($target_type)->load($type['target_id']); - if ($referenced_entity->hasField('field_external_uri') && - !empty($referenced_entity->get('field_external_uri')->getValue())) { - foreach ($referenced_entity->get('field_external_uri')->getValue() as $value) { + if ($referenced_entity->hasField(IslandoraUtils::EXTERNAL_URI_FIELD) && + !empty($referenced_entity->get(IslandoraUtils::EXTERNAL_URI_FIELD)->getValue())) { + foreach ($referenced_entity->get(IslandoraUtils::EXTERNAL_URI_FIELD)->getValue() as $value) { $elem['@type'][] = $value['uri']; } }