public function EasyRdf_Graph::all

Get all values for a property path

This method will return an empty array if the property does not exist.

Parameters

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

string $propertyPath A valid property path:

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

7 calls to EasyRdf_Graph::all()
EasyRdf_Graph::allLiterals in drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php
Get all literal values for a property of a resource
EasyRdf_Graph::allOfType in drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php
Get all the resources in the graph of a certain type
EasyRdf_Graph::allResources in drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php
Get all resources for a property of a resource
EasyRdf_Graph::count in drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php
Count all values for a property of a resource
EasyRdf_Graph::isA in drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php
Check if a resource is of the specified type

... See full list

File

drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php, line 735

Class

EasyRdf_Graph
Container for collection of EasyRdf_Resources.

Code

public function all($resource, $propertyPath, $type = null, $lang = null) {
  $this
    ->checkResourceParam($resource);
  if (is_object($propertyPath) and $propertyPath instanceof EasyRdf_Resource) {
    return $this
      ->allForSingleProperty($resource, $propertyPath
      ->getUri(), $type, $lang);
  }
  elseif (is_string($propertyPath) and preg_match('|^(\\^?)<(.+)>|', $propertyPath, $matches)) {
    return $this
      ->allForSingleProperty($resource, "{$matches[1]}{$matches[2]}", $type, $lang);
  }
  elseif ($propertyPath === null or !is_string($propertyPath)) {
    throw new InvalidArgumentException("\$propertyPath should be a string or EasyRdf_Resource and cannot be null");
  }
  elseif ($propertyPath === '') {
    throw new InvalidArgumentException("\$propertyPath cannot be an empty string");
  }
  $objects = array(
    $resource,
  );

  // Loop through each component in the path
  foreach (explode('/', $propertyPath) as $part) {
    $results = array();
    foreach (explode('|', $part) as $p) {
      foreach ($objects as $o) {

        // Ignore literals found earlier in path
        if ($o instanceof EasyRdf_Literal) {
          continue;
        }
        $results = array_merge($results, $this
          ->allForSingleProperty($o, $p, $type, $lang));
      }
    }

    // Stop if we don't have anything
    if (empty($objects)) {
      break;
    }

    // Use the results as the input to the next iteration
    $objects = $results;
  }
  return $objects;
}