Browse Source

Switch @value to @id (#140)

pull/729/head
Jared Whiklo 6 years ago committed by dannylamb
parent
commit
ba806fd719
  1. 4
      src/Plugin/ContextReaction/MappingUriPredicateReaction.php
  2. 6
      tests/src/Functional/MappingUriPredicateReactionTest.php

4
src/Plugin/ContextReaction/MappingUriPredicateReaction.php

@ -91,7 +91,7 @@ class MappingUriPredicateReaction extends NormalizerAlterReaction {
$tmp = $graph[$drupal_predicate]; $tmp = $graph[$drupal_predicate];
$graph[$drupal_predicate] = [$tmp]; $graph[$drupal_predicate] = [$tmp];
} }
elseif (array_search($url, array_column($graph[$drupal_predicate], '@value'))) { elseif (array_search($url, array_column($graph[$drupal_predicate], '@id'))) {
// Don't add it if it already exists. // Don't add it if it already exists.
return; return;
} }
@ -99,7 +99,7 @@ class MappingUriPredicateReaction extends NormalizerAlterReaction {
else { else {
$graph[$drupal_predicate] = []; $graph[$drupal_predicate] = [];
} }
$graph[$drupal_predicate][] = ["@value" => $url]; $graph[$drupal_predicate][] = ["@id" => $url];
return; return;
} }
} }

6
tests/src/Functional/MappingUriPredicateReactionTest.php

@ -107,7 +107,7 @@ class MappingUriPredicateReactionTest extends IslandoraFunctionalTestBase {
); );
$this->assertEquals( $this->assertEquals(
"$url?_format=jsonld", "$url?_format=jsonld",
$json['@graph'][0]['http://www.w3.org/2002/07/owl#sameAs'][0]['@value'], $json['@graph'][0]['http://www.w3.org/2002/07/owl#sameAs'][0]['@id'],
'Missing alter added predicate.' 'Missing alter added predicate.'
); );
@ -129,7 +129,7 @@ class MappingUriPredicateReactionTest extends IslandoraFunctionalTestBase {
$json['@graph'][0], 'Still has old predicate'); $json['@graph'][0], 'Still has old predicate');
$this->assertEquals( $this->assertEquals(
"$url?_format=jsonld", "$url?_format=jsonld",
$json['@graph'][0]['http://example.org/first/second'][0]['@value'], $json['@graph'][0]['http://example.org/first/second'][0]['@id'],
'Missing alter added predicate.' 'Missing alter added predicate.'
); );
} }
@ -181,7 +181,7 @@ class MappingUriPredicateReactionTest extends IslandoraFunctionalTestBase {
$json = \GuzzleHttp\json_decode($new_contents, TRUE); $json = \GuzzleHttp\json_decode($new_contents, TRUE);
$this->assertEquals( $this->assertEquals(
"$media_url?_format=jsonld", "$media_url?_format=jsonld",
$json['@graph'][0]['http://www.iana.org/assignments/relation/describedby'][0]['@value'], $json['@graph'][0]['http://www.iana.org/assignments/relation/describedby'][0]['@id'],
'Missing alter added predicate.' 'Missing alter added predicate.'
); );
$this->assertEquals( $this->assertEquals(

Loading…
Cancel
Save