You are here

public function EntityUsage::deleteByField in Entity Usage 8.4

Same name and namespace in other branches
  1. 8.2 src/EntityUsage.php \Drupal\entity_usage\EntityUsage::deleteByField()

Delete all records for a given field_name + source_type.

Parameters

string $source_type: The source entity type.

string $field_name: The name of the field in the source entity using the target entity.

Overrides EntityUsageInterface::deleteByField

File

src/EntityUsage.php, line 190

Class

EntityUsage
Defines the entity usage base class.

Namespace

Drupal\entity_usage

Code

public function deleteByField($source_type, $field_name) {
  $query = $this->connection
    ->delete($this->tableName)
    ->condition('source_type', $source_type)
    ->condition('field_name', $field_name);
  $query
    ->execute();
  $event = new EntityUsageEvent(NULL, NULL, NULL, $source_type, NULL, NULL, NULL, $field_name, NULL);
  $this->eventDispatcher
    ->dispatch(Events::DELETE_BY_FIELD, $event);
}