You are here

protected function EasyRdf_Graph::classForResource in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php \EasyRdf_Graph::classForResource()

Work out the class to instantiate a resource as @ignore

2 calls to EasyRdf_Graph::classForResource()
EasyRdf_Graph::dumpResource in vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php
Return a human readable view of a resource and its properties
EasyRdf_Graph::resource in vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php
Get or create a resource stored in a graph

File

vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php, line 158

Class

EasyRdf_Graph
Container for collection of EasyRdf_Resources.

Code

protected function classForResource($uri) {
  $rdfType = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type';
  if (isset($this->index[$uri][$rdfType])) {
    foreach ($this->index[$uri][$rdfType] as $type) {
      if ($type['type'] == 'uri' or $type['type'] == 'bnode') {
        $class = EasyRdf_TypeMapper::get($type['value']);
        if ($class != null) {
          return $class;
        }
      }
    }
  }

  // Parsers don't typically add a rdf:type to rdf:List, so we have to
  // do a bit of 'inference' here using properties.
  if ($uri == 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil' or isset($this->index[$uri]['http://www.w3.org/1999/02/22-rdf-syntax-ns#first']) or isset($this->index[$uri]['http://www.w3.org/1999/02/22-rdf-syntax-ns#rest'])) {
    return 'EasyRdf_Collection';
  }
  return 'EasyRdf_Resource';
}