protected function EasyRdf_Graph::checkResourceParam

Check that a URI/resource parameter is valid, and convert it to a string @ignore

28 calls to EasyRdf_Graph::checkResourceParam()
EasyRdf_Graph::add in drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php
Add data to the graph
EasyRdf_Graph::addLiteral in drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php
Add a literal value as a property of a resource
EasyRdf_Graph::addResource in drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php
Add a resource as a property of another resource
EasyRdf_Graph::addType in drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php
Add one or more rdf:type properties to a resource
EasyRdf_Graph::all in drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php
Get all values for a property path

... See full list

File

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

Class

EasyRdf_Graph
Container for collection of EasyRdf_Resources.

Code

protected function checkResourceParam(&$resource, $allowNull = false) {
  if ($allowNull == true) {
    if ($resource === null) {
      if ($this->uri) {
        $resource = $this->uri;
      }
      else {
        return;
      }
    }
  }
  elseif ($resource === null) {
    throw new InvalidArgumentException("\$resource cannot be null");
  }
  if (is_object($resource) and $resource instanceof EasyRdf_Resource) {
    $resource = $resource
      ->getUri();
  }
  elseif (is_object($resource) and $resource instanceof EasyRdf_ParsedUri) {
    $resource = strval($resource);
  }
  elseif (is_string($resource)) {
    if ($resource == '') {
      throw new InvalidArgumentException("\$resource cannot be an empty string");
    }
    elseif (preg_match("|^<(.+)>\$|", $resource, $matches)) {
      $resource = $matches[1];
    }
    else {
      $resource = EasyRdf_Namespace::expand($resource);
    }
  }
  else {
    throw new InvalidArgumentException("\$resource should be a string or an EasyRdf_Resource");
  }
}