You are here

protected function EasyRdf_Graph::allForSingleProperty in Zircon Profile 8.0

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

Get all values for a single property of a resource

@ignore

Parameters

string $resource The URI of the resource (e.g. http://example.com/joe#me):

string $property The name of the property (e.g. foaf:name):

string $type The type of value to filter by (e.g. literal):

string $lang The language to filter by (e.g. en):

Return value

array An array of values associated with the property

1 call to EasyRdf_Graph::allForSingleProperty()
EasyRdf_Graph::all in vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php
Get all values for a property path

File

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

Class

EasyRdf_Graph
Container for collection of EasyRdf_Resources.

Code

protected function allForSingleProperty($resource, $property, $type = null, $lang = null) {
  $this
    ->checkResourceParam($resource);
  $this
    ->checkSinglePropertyParam($property, $inverse);

  // Get an array of values for the property
  $values = $this
    ->propertyValuesArray($resource, $property, $inverse);
  if (!isset($values)) {
    return array();
  }
  $objects = array();
  if ($type) {
    foreach ($values as $value) {
      if ($type == 'literal' and $value['type'] == 'literal') {
        if ($lang == null or isset($value['lang']) and $value['lang'] == $lang) {
          $objects[] = $this
            ->arrayToObject($value);
        }
      }
      elseif ($type == 'resource') {
        if ($value['type'] == 'uri' or $value['type'] == 'bnode') {
          $objects[] = $this
            ->arrayToObject($value);
        }
      }
    }
  }
  else {
    foreach ($values as $value) {
      $objects[] = $this
        ->arrayToObject($value);
    }
  }
  return $objects;
}