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:----JL2XeNRR0uf+tMIPSfcAB/jtYRJseImt1NHMrZEUnLW4SX3PAqe7gvrkX+jh6w8+mOgQ3bOn6r396OFSS7kq/VmZkJ45gqsaKovCZ494Rc75AVIpVdypZmfNbjcRSp+ybDubPapyjfC+eXQtL4AkXMiYmUkuzLNuRng5vqPaucaB9sOGvH3KMiF1POHHJ7CMd+8UWyb+A6ybqeJZXn+EssLc/8nI36bcOOoP1vbPyGCQlUY0leWQ0UaTvHbLgd3FWY2rUsHcLKfKHNKjvdEU7qWYmbzikZLgz2fgQqPwFTsk82McEjqItvMZm2qgYpxHJbiGiazcNx0ZxGePluW16KhrAYTtx9dzAKECYSgB+3gPeb9J/q/Zgu0hXct59iGopRelIJ41gUMp8TYUYbDVXqpsGoLAI9ISIBbvtdKgvJJORq8F50wupEP1n43eWgv1A2vjV18qCfDirR4KXcs7QNiBdiUrCi9z8vg34pzM1ZWo+FO8BsnotYnNPLeseE51+Eh95u9lU3sTteMAPo8GcHAXjOtuCL+hlKIEouRZvpqXxcjoVxt6e3lEgP7MevvRJjiVon2if7czuNlTLB+dKHiOGDm5akUYsD4ilV0z6wkdkBq5AEfIGEZxlR9VGK8UZhH73H9PtsOWqT2BnUXLuiwI3y7MjdphOSPQgWAEEzI=----ATTACHMENT:----NTUzMzkwNDQ3OTM0OTYwNyAxMjg4OTc3MTUzMzg3NDMxIDQxNDU1NjQ5NzQxNzY2MjA=