public function EasyRdf_Graph::delete

Delete a property (or optionally just a specific value)

Parameters

mixed $resource The resource to delete the property from:

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

mixed $value The value to delete (null to delete all values):

Return value

integer The number of values deleted

5 calls to EasyRdf_Graph::delete()
EasyRdf_Graph::deleteLiteral in drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php
Delete a literal value from a property of a resource
EasyRdf_Graph::deleteResource in drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php
Delete a resource from a property of another resource
EasyRdf_Graph::set in drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php
Set a value for a property
EasyRdf_Graph::setType in drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php
Change the rdf:type property for a resource
EasyRdf_Graph::__unset in drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php
Magic method to delete a property of the graph

File

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

Class

EasyRdf_Graph
Container for collection of EasyRdf_Resources.

Code

public function delete($resource, $property, $value = null) {
  $this
    ->checkResourceParam($resource);
  $this
    ->checkSinglePropertyParam($property, $inverse);
  $this
    ->checkValueParam($value);
  $count = 0;
  $property = EasyRdf_Namespace::expand($property);
  if (isset($this->index[$resource][$property])) {
    foreach ($this->index[$resource][$property] as $k => $v) {
      if (!$value or $v == $value) {
        unset($this->index[$resource][$property][$k]);
        $count++;
        if ($v['type'] == 'uri' or $v['type'] == 'bnode') {
          $this
            ->deleteInverse($v['value'], $property, $resource);
        }
      }
    }

    // Clean up the indexes - remove empty properties and resources
    if ($count) {
      if (count($this->index[$resource][$property]) == 0) {
        unset($this->index[$resource][$property]);
      }
      if (count($this->index[$resource]) == 0) {
        unset($this->index[$resource]);
      }
    }
  }
  return $count;
}