EntityUsageTrackBase.php in Entity Usage 8
File
src/EntityUsageTrackBase.php
View source
<?php
namespace Drupal\entity_usage;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Plugin\PluginBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
abstract class EntityUsageTrackBase extends PluginBase implements EntityUsageTrackInterface, ContainerFactoryPluginInterface {
protected $usageService;
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityUsage $usage_service) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->configuration += $this
->defaultConfiguration();
$this->usageService = $usage_service;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('entity_usage.usage'));
}
public function defaultConfiguration() {
return [];
}
public function getId() {
return $this->pluginDefinition['id'];
}
public function getLabel() {
return $this->pluginDefinition['label'];
}
public function getDescription() {
return $this->pluginDefinition['description'];
}
public function trackOnEntityCreation(ContentEntityInterface $entity) {
}
public function trackOnEntityUpdate(ContentEntityInterface $entity) {
}
public function trackOnEntityDeletion(ContentEntityInterface $entity) {
}
}