public function EntityUsage::deleteUsage in Entity Usage 8.3
Remove a usage record.
Parameters
int|string $target_id: The target entity ID.
string $target_type: The target entity type.
int|string $source_id: The source entity ID.
string $source_type: The source entity type.
string $source_langcode: The source entity language code.
string $source_vid: The source entity revision ID.
Overrides EntityUsageInterface::deleteUsage
File
- src/
EntityUsage.php, line 137
Class
- EntityUsage
- Defines the entity usage base class.
Namespace
Drupal\entity_usageCode
public function deleteUsage($target_id, $target_type, $source_id, $source_type, $source_langcode, $source_vid) {
$target_id_column = $this
->isInt($target_id) ? 'target_id' : 'target_id_string';
$source_id_column = $this
->isInt($source_id) ? 'source_id' : 'source_id_string';
$query = $this->connection
->delete($this->tableName)
->condition('target_type', $target_type)
->condition($target_id_column, $target_id)
->condition('source_type', $source_type)
->condition($source_id_column, $source_id)
->condition('source_langcode', $source_langcode)
->condition('source_vid', $source_vid);
$query
->execute();
$event = new EntityUsageEvent($target_id, $target_type, $source_id, $source_type, $source_langcode, $source_vid);
$this->eventDispatcher
->dispatch(Events::BULK_DELETE_SOURCES, $event);
}