EntityUsageInterface.php in Entity Usage 8.3
Same filename and directory in other branches
Namespace
Drupal\entity_usageFile
src/EntityUsageInterface.phpView source
<?php
namespace Drupal\entity_usage;
use Drupal\Core\Entity\EntityInterface;
/**
* Entity usage interface.
*/
interface EntityUsageInterface {
/**
* Register a new usage record.
*
* Note that this method will honor the settings defined on the configuration
* page, hence potentially ignoring the register if the settings for the
* called combination are to not track this usage. Also, the hook
* hook_entity_usage_block_tracking() will be invoked, so other modules will
* have an opportunity to block this record before it is written to DB.
*
* @param int|string $target_id
* The target entity ID.
* @param string $target_type
* The target entity type.
* @param int|string $source_id
* The source entity ID.
* @param string $source_type
* The source entity type.
* @param string $source_langcode
* The source entity language code.
* @param string $source_vid
* The source entity revision ID.
*/
public function registerUsage($target_id, $target_type, $source_id, $source_type, $source_langcode, $source_vid);
/**
* Remove a usage record.
*
* @param int|string $target_id
* The target entity ID.
* @param string $target_type
* The target entity type.
* @param int|string $source_id
* The source entity ID.
* @param string $source_type
* The source entity type.
* @param string $source_langcode
* The source entity language code.
* @param string $source_vid
* The source entity revision ID.
*/
public function deleteUsage($target_id, $target_type, $source_id, $source_type, $source_langcode, $source_vid);
/**
* Remove all records of a given target entity type.
*
* @param string $target_type
* The target entity type.
*/
public function bulkDeleteTargets($target_type);
/**
* Remove all records of a given source entity type.
*
* @param string $source_type
* The source entity type.
*/
public function bulkDeleteSources($source_type);
/**
* Delete all records for a given source entity.
*
* @param int|string $source_id
* The source entity ID.
* @param string $source_type
* The source entity type.
* @param string $source_langcode
* (optional) The source entity language code. Defaults to NULL.
* @param string $source_vid
* (optional) The source entity revision ID. Defaults to NULL.
*/
public function deleteBySourceEntity($source_id, $source_type, $source_langcode = NULL, $source_vid = NULL);
/**
* Delete all records for a given target entity.
*
* @param int|string $target_id
* The target entity ID.
* @param string $target_type
* The target entity type.
*/
public function deleteByTargetEntity($target_id, $target_type);
/**
* Provide a list of all referencing source entities for a target entity.
*
* Examples:
* - Return example 1:
* [
* 'node' => [
* 123 => [
* 'source_langcode' => 'en',
* 'source_vid' => '128',
* ],
* 124 => [
* 'source_langcode' => 'en',
* 'source_vid' => '129',
* ],
* ],
* 'user' => [
* 2 => [
* 'source_langcode' => 'en',
* 'source_vid' => '2',
* ],
* ],
* ]
* - Return example 2:
* [
* 'entity_reference' => [
* 'node' => [...],
* 'user' => [...],
* ]
* ]
*
* @param \Drupal\Core\Entity\EntityInterface $target_entity
* A target entity.
* @param bool $nest_results
* (optional) Whether the results should be returned in a nested structure.
* Defaults to TRUE.
*
* @return array
* A nested array with usage data. The first level is keyed by the type of
* the source entities, the second by the source id. The value of the second
* level contains all other information like the source language code or
* source revision ID. If $nest_results is FALSE, the returned array will
* be an indexed array where values are arrays containing all DB columns
* for the records.
*/
public function listSources(EntityInterface $target_entity, $nest_results = TRUE);
/**
* Provide a list of all referenced target entities for a source entity.
*
* @param \Drupal\Core\Entity\EntityInterface $source_entity
* The source entity to check for references.
*
* @return array
* An associative array where keys are target entity types, and values are
* indexed arrays of target entity IDs.
*/
public function listTargets(EntityInterface $source_entity);
}
Interfaces
Name | Description |
---|---|
EntityUsageInterface | Entity usage interface. |