Resource Helper Class

arenou edited this page Aug 24, 2015 · 2 revisions

While ARC is mainly based on array structures, it also supports a basic "Resource" helper class for convenient access to elements in an ARC resource index. The resource class can auto-fetch and cache Linked Data, use a passed list of predicates/objects, or query an ARC RDF store (local or remote).


$conf = array(
  'ns' => array(
    'rdf' => '',
    'rdfs' => '',
    'dbpedia' => ''
$res = ARC2::getResource($conf);

Setting the current URI (pointer)


Retrieving a single predicate value

If no store or predicate array is set (see below), the resource object will automatically retrieve RDF data from the resource URI.

$population = $res->getPropValue('dbpedia:populationTotal');

Setting the predicates/objects manually

$props = array(
  "" => array(...),

Telling the resource to fetch data from an RDF store

$store = ARC2::getStore($conf);

Retrieving all values for a given predicate

$labels = $res->getPropValues('rdfs:label');

Retrieving all predicates and objects (datatype and language information preserved)

$props = $res->getProps();
$labels_full = $res->getProps('rdfs:label');

Checking the existence of a certain property value

$is_eu_capital = $res->hasPropValue('rdf:type', '');