/** * Proceeds to a copy of resource provided as argument and stores it. * * @param BaseResource $resource * * @return BaseResource */ public function takeSnapshot($resource) { $res = $this->resource($resource->getUri()); $graph = $resource->getGraph(); foreach ($graph->toRdfPhp() as $resource2 => $properties) { if ($resource2 !== $res->getUri()) { continue; } if (!$this->unitOfWork->isManagementBlackListed($resource2)) { foreach ($properties as $property => $values) { foreach ($values as $value) { if ($value['type'] === 'bnode' || $value['type'] === 'uri') { $this->addResource($resource2, $property, $value['value']); } elseif ($value['type'] === 'literal') { $this->addLiteral($resource2, $property, Literal::create($value['value'], isset($value['lang']) ? $value['lang'] : null, isset($value['datatype']) ? $value['datatype'] : null)); } else { } } } } } return $res; }
/** Create a new EasyRdf\Resource or EasyRdf\Literal depending * on the type of data passed in. * * @ignore */ protected function newTerm($data) { switch ($data['type']) { case 'bnode': return new Resource('_:' . $data['value']); case 'uri': return new Resource($data['value']); case 'literal': case 'typed-literal': return Literal::create($data); default: throw new Exception("Failed to parse SPARQL Query Results format, unknown term type: " . $data['type']); } }