Issue #3015287 by johannijdam, seanB, ricovandevin: Allow usage records to be...
11 unresolved threads
Merge request reports
Activity
added 1 commit
54 54 Go to the URL /admin/config/entity-usage/batch-update in order to start the 55 55 batch operation. 56 56 57 Tracking using background process 58 ============ 59 The module supports tracking entity usage via a background process. When the 60 entity usage is tracked via a background process, the tracking information will 61 be updated after the page was loaded in the background. 62 63 Since this is for advanced users only, this setting is not exposed in the UI. - src/EntityUsageBackgroundTracking.php 0 → 100644
84 case static::OPERATION_TRANSLATION_DELETE: 85 $this->entityUsageUpdateManager->trackUpdateOnDeletion($entity, 'translation'); 86 break; 87 88 case static::OPERATION_REVISION_DELETE: 89 $this->entityUsageUpdateManager->trackUpdateOnDeletion($entity, 'revision'); 90 break; 91 } 92 } 93 } 94 } 95 96 /** 97 * Add an entity for background tracking. 98 * 99 * @param string $operation - src/EntityUsageBackgroundTracking.php 0 → 100644
1 <?php 2 3 namespace Drupal\entity_usage; 4 5 use Drupal\Core\DestructableInterface; 6 use Drupal\Core\Entity\EntityInterface; 7 8 /** 9 * Track entity usage in the background. 10 */ 11 class EntityUsageBackgroundTracking implements DestructableInterface { - src/EntityUsageBackgroundTracking.php 0 → 100644
1 <?php 2 3 namespace Drupal\entity_usage; 4 5 use Drupal\Core\DestructableInterface; 6 use Drupal\Core\Entity\EntityInterface; 7 8 /** 9 * Track entity usage in the background. 10 */ 11 class EntityUsageBackgroundTracking implements DestructableInterface { 12 13 /** 14 * Key for the insert operation. 15 */ 16 const OPERATION_INSERT = 'insert'; 19 19 arguments: ['@entity_type.manager', '@config.factory'] 20 20 tags: 21 21 - { name: event_subscriber } 22 entity_usage.background_tracking: 23 class: Drupal\entity_usage\EntityUsageBackgroundTracking 24 arguments: ['@entity_usage.entity_update_manager'] 19 19 arguments: ['@entity_type.manager', '@config.factory'] 20 20 tags: 21 21 - { name: event_subscriber } 22 entity_usage.background_tracking: - src/EntityUsageBackgroundTracking.php 0 → 100644
56 * Constructs a new background tracking service. 57 * 58 * @param \Drupal\entity_usage\EntityUpdateManager $entity_usage_update_manager 59 * The entity usage update manager. 60 */ 61 public function __construct(EntityUpdateManager $entity_usage_update_manager) { 62 $this->entityUsageUpdateManager = $entity_usage_update_manager; 63 } 64 65 /** 66 * {@inheritdoc} 67 */ 68 public function destruct() { 69 foreach ($this->entity_operations as $operation => $entities) { 70 foreach ($entities as $entity) { 71 switch ($operation) { - src/EntityUsageBackgroundTracking.php 0 → 100644
31 const OPERATION_TRANSLATION_DELETE = 'translation_delete'; 32 33 /** 34 * Key for the revision delete operation. 35 */ 36 const OPERATION_REVISION_DELETE = 'revision_delete'; 37 38 /** 39 * A list of entities that should be tracked per operation. 40 * 41 * The nested array is keyed by operation and has arrays of entities to index 42 * for the specific operation as values. 43 * 44 * @var \Drupal\Core\Entity\EntityInterface[][] 45 */ 46 protected $entity_operations = []; - src/EntityUsageBackgroundTracking.php 0 → 100644
31 const OPERATION_TRANSLATION_DELETE = 'translation_delete'; 32 33 /** 34 * Key for the revision delete operation. 35 */ 36 const OPERATION_REVISION_DELETE = 'revision_delete'; 37 38 /** 39 * A list of entities that should be tracked per operation. 40 * 41 * The nested array is keyed by operation and has arrays of entities to index 42 * for the specific operation as values. 43 * 44 * @var \Drupal\Core\Entity\EntityInterface[][] 45 */ 46 protected $entity_operations = []; - src/EntityUsageBackgroundTracking.php 0 → 100644
90 break; 91 } 92 } 93 } 94 } 95 96 /** 97 * Add an entity for background tracking. 98 * 99 * @param string $operation 100 * The operation causing changes in entity usage. 101 * @param \Drupal\Core\Entity\EntityInterface $entity 102 * The entity to track. 103 */ 104 public function registerEntity($operation, EntityInterface $entity) { 105 $this->entity_operations[$operation][] = clone $entity; - src/EntityUsageBackgroundTracking.php 0 → 100644
2 3 namespace Drupal\entity_usage; 4 5 use Drupal\Core\DestructableInterface; 6 use Drupal\Core\Entity\EntityInterface; 7 8 /** 9 * Track entity usage in the background. 10 */ 11 class EntityUsageBackgroundTracking implements DestructableInterface { 12 13 /** 14 * Key for the insert operation. 15 */ 16 const OPERATION_INSERT = 'insert'; 17
Please register or sign in to reply