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:----X9GG1egJkDw1FkS48HuG8P/h43nzulQxgH0T89/ZNrMQ3j4nFtLgpoU9zmP/7D2p3q3KWS0Q0s2cITU9j2+mG5ux4F/bO3tluWiUUuaDyp+9v0430rM7V6p4VAQT5S2kYU6uFGJtLeZi+bQquB6PXJZnac7XuH9mGf/VGYZifO6IbyQdJbueOj/JbI7m5CzNS7hi602nKCaJ7+r7GeupPS4SiSIsvKByuJ1zXS33PnfBiZh8ZwDe82gftX0ZwDIHzGZL+31slWbkvbqISoISg42rOeSe3DY9hYGGJXe9anQlHaWK5uUGz8O5sb/dqmpfqxlJJ65DfXtCij+syVDfvvvKXpl/A70ATTGymGkqZM4zUAcj60ziK34CbjammKYeg1ne70Nlw5qCoB4tg8EhjClE7R/knqItJwr0jDrPnXshgViMY6EIHL9N1rZEdegFn9Pf/JNHEg9SOG1PoP27TXLW10BNojaEDnmK1xuRTUd9R0/Q2p2JK0vuHP7jbu9bl8pqitcu2wWBW3eHmNUqJzgip0VsxDpw//k8B8jboY9Ukxt5Nbtr+bCOxxESX/Ak+NeNpNJbFvfVfW8cOq5Iy7LX3KtZU/GnRh5MqloqvtJ5XWowOb7MKpIOcd3uAMi4QQSp3FlpSSwPCOPk5ImWKzy5Os3X09ACg9ved2DeeEY=----ATTACHMENT:----MzAwNzgwNTk4MTgzNjU0OCA4OTY5OTg0ODkyNTk5OTk0IDM4MzIzMzExMjY1NDM0NTc=