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:----QS34D8siMTakA2lQDHvHgWEbKNcpk1j+ChKUTYAqc5Yd1s/KXoI+z8I21NcLgR7EcADNCj+LcgJhPdXmeh1yLJ0xTZxPMmUIbJgiM+OGlIC+Hp4khF41OPoNh+HHYzYkuWevmfItK+FB6kUaiaa7TRRckgSbPCSFcvdIyPAwYVwSn/qjY9aseuEXr+XUkAvdK0LsVhacK0/MzODvIE5gCxScZ4PUIQEbzSkqR9HvpS8CzWAY0f+GVRn79OlVIxGufiJDekRVCpVnDy/gjtJiCTmvt+4dv7uoRhEwq9gqdbY2hetU6LoaJfZuiqyu3ch8ZOvOmak4yDWTyDjls4jzfA1HLDuVdwrfK9475bqhFnKmYJ/yYTPnpGGkERDCWwf9qZvMgiqtAsU+EeJ2iA4U5XMMXOx/33mB0pG7xYNySQVVVo5sIeiab2Os+e8btfariSo9ACeBIg7OYG1++EcEl8r7PATEPLBNihiXwuaa6cvX1U54VoN33Vu8Ucg+xeUzaIUnxzqFmu6+t4nT7e15Ib9qc8IqaKQLNeJQ29/kpvwdWN/jUjzf3JGHLTmyYYrOoN546BGmsfXWy73VKVva2Lo+fkILhf/5dBC8VAOL5y6XlQrcL45ztx8+zewoiDLf31U1wZ635krCDn1QKnNzUEra4dkVUwAfM2Fw1Qumw+s=----ATTACHMENT:----MTgzOTk2ODE4NTMyNjc5MCA5MTQzMDg0Njg1Mzc2Mzc0IDk4MzQwMTQ0MzIzMzkxMzg=