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:----IfjwZo2jeNCOHUYUsSyL3mbUf/5bRWD1JiqWrXZ6oAXSAwlloSbDAaqHljy6+a8XaAOtUJpkmPUnSraTfyithn77IveiPHducRU5bMIBjDSmwIPaKUcHhFRDhzzLCcFbKI78T5ZVdHQBFm9JJXIPYCAPDiQf7NXzL7TGv3Hv2OOUqIf7SKNcebdy/0vXdCgbGHgP5Ik1ADca9V36AOD3dXiPTwkw2MYI8Kfx9fdowJwdkcMqu3O2Lbh3bzEQ4x5DAcIGL8KlUzUM6omHHlVzwJtA+BNsfAtPmxVHK4YJpDzQofrnvEA479wxjILCfSUlAVpGe1y3eEPuznEBoA/j9zsN1y2UWeiEtXYXXxBe5t/6S1YsQg14wOuwf3S7Y/I4vi3qsDKKFAZqj8I9ZwSSFY1OMzCs3Hw21/LUPt3Q4qnwGxTtV0tY+dADAwMq472lVwe49keXuoeHuhtvdBzBvZ+tpQjvgydsoJbSYx2UJqDICVBYhlH6AAZj1n16fJ44VBM3vvjkaooGsrLnpylcFoNkCcivw2zrHFypJ+4QwgtU62eDr3oTV3Xw6XtXaOmxTK1NpyBUTil8tnMuydM7oqZpPwKQd8PNgE+60+1ZyJknkKubhqaiEniF6WjUIKgFV/UbsiKLxwY0B3d9QJjidyZsgGurZ+CVASJDMQnYhmU=----ATTACHMENT:----Mzk4MTg1MTY1MDU2Njg2NiA4Nzc4MDAyMTg1MzEyOTU1IDk3ODcxMzk0MDI3NTAyNDU=