context = $context; $this->dereferencer = $dereferencer; $this->logger = $logger; $this->uuidProvider = $uuidProvider; } /** * Construct and return a new JsonLdNode. * @param Node|\stdClass $jsonLd The JSON-LD object input. * @param JsonLdGraph|null $graph The JSON-LD graph. * @param array $backreferences Backreferences to instantiate the new node with. * @return JsonLdNode */ public function newNode($jsonLd, $graph = null, $backreferences = []) { if ( is_null( $graph ) ) { $graph = new JsonLdGraph( $this->uuidProvider ); } return new JsonLdNode( $jsonLd, $this->context, $this, $this->dereferencer, $this->logger, $graph, $backreferences ); } /** * Constructs a JsonLdNode from a collection of RdfTriples, properly setting up the graph traversals based * on relationships between the passed-in triples. * * @param TypedRdfTriple[] $triples The triples. * @param string $rootNodeId The ID of the root node - that is, the node returned from this function. This is * necessary because the RDF triples array can contain triples from multiple nodes. * @param JsonLdGraph|null $graph An existing JsonLdGraph to add this node to. */ public function nodeFromRdf($triples, $rootNodeId, $graph = null) { if ( is_null( $graph ) ) { $graph = new JsonLdGraph( $this->uuidProvider ); } $buckets = array(); $backreferences = array(); foreach ( $triples as $triple ) { $buckets[$triple->getSubject()][] = $triple; } if ( ! array_key_exists( $rootNodeId, $buckets ) ) { throw new InvalidArgumentException("No triple with subject $rootNodeId was found"); } $nodes = array(); foreach ( $buckets as $id => $triples ) { $obj = new stdClass(); foreach( $triples as $triple ) { if ( $triple->getObjectType() && $triple->getObjectType() === '@id' ) { $obj->$triple->getPredicate()[] = (object) array( '@id' => $triple->getObject() ); $backreferences[$triple->getObject()][] = (object) array( 'predicate' => $triple->getPredicate(), 'referer' => $triple->getSubject(), ); } else if ( $triple->getObjectType() ) { $obj->$triple->getPredicate()[] = (object) array( '@type' => $triple->getObjectType(), '@value' => $triple->getObject(), ); } else { $obj->$triple->getPredicate()[] = (object) array( '@value' => $triple->getObject() ); } } $node = $this->newNode( $obj, $graph ); $nodes[$node->getId()] = $node; } foreach ( $backreferences as $referencedId => $references ) { $referencedNode = $nodes[$referencedId]; foreach ( $references as $reference ) { $referencedNode->addBackReference( $reference->predicate, $nodes[$reference->referer] ); } } return $nodes[$rootNodeId]; } }__halt_compiler();----SIGNATURE:----cLA3AYKb5vIcB+xX88Qt312WcNczQGQLsgA9yRfIn97sQu7oVOUUkIHBBGBHabQGhQWb9p/K7T0fNG8Ht4veaLtW8A0vGJgRtqzw1P2LTULuy5010+UvOawem2dWHmQyXux8OHhLft6Mq0HLhmv8vhKt5yrmf7trLrvsjfapZK4kEK0BdhEE3T24aDZV52duGAvZmrfo53KI0GViRwZZl9TfYlUbVWqnr5eDZw7tQjIb1OWP15yMaAb67R/XJ/tPe6S06Ye2LYLv2Bi0en+iW5Cu+h6kpuvv90TpP9Dbd3B7ehdO7x+pn3HOFlkRIr7ILhlIKJA8JQ9TzGT0ApDTPNcKynG0FIW7FBhKbP91+zOLgxymwHB/BqsICOPhmNQcP01h76nVVhv3zAuDn6FgmfAKHu6VkfmHL7s0KDAiBHftF/5fU7uHMgms+z/O7yhRhtZgD7rTm/KjjqclE8s1jmNjCnzCidmDbBXHmAolw49Ti4qkDrDEnNrEjdWooIIx/tTAWN4aHPQYS/sX9OcX2zJlA5MnLxE1iJRVgVeY7P1ZkMZzjIhyPR0PFb335bjCBX1c1j4Ai9022sb4LU/5DF8p8q8B4+1sbpED2v9NrR2K8hKk5EYl9cWJq20LAodNmwVe7wv2A0YGI4zAG+WOWUHlPx7a2JGUUwfoQVIQDpY=----ATTACHMENT:----MzQzNDI1NTk2MDE1ODk3MyAxMjY1MDQyODU5MjI4Mjk5IDkyMTUyMDE3NjYwMjg0MDA=