Skip to content
This repository has been archived by the owner on Jul 27, 2022. It is now read-only.

Commit

Permalink
Set the default graph on entity creation.
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiu-cristea committed Oct 6, 2019
1 parent 8b66978 commit af74fd6
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/SparqlEntityStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\sparql_entity_storage\Database\Driver\sparql\ConnectionInterface;
use Drupal\sparql_entity_storage\Entity\Query\Sparql\SparqlArg;
use Drupal\sparql_entity_storage\Entity\SparqlGraph;
use Drupal\sparql_entity_storage\Exception\DuplicatedIdException;
use EasyRdf\Graph;
use EasyRdf\Literal;
Expand Down Expand Up @@ -186,6 +187,19 @@ protected static function getGraph($graph_uri) {
return $graph;
}

/**
* {@inheritdoc}
*/
public function create(array $values = []) {
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
$entity = parent::create($values);
// Ensure the default graph if no explicit graph has been set.
if ($entity->get('graph')->isEmpty()) {
$entity->set('graph', SparqlGraph::DEFAULT);
}
return $entity;
}

/**
* {@inheritdoc}
*/
Expand Down

0 comments on commit af74fd6

Please sign in to comment.