Open Data Catalog v2.0.0
TableTrait.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Drupal\datastore;
4 
10 trait TableTrait {
11 
15  public function jobstorePrune($uuid) {
16  if (!isset($this->resourceLocalizer)) {
17  \Drupal::logger('datastore')->error('ResourceLocalizer is not set.');
18  return;
19  }
20  $resource = $this->resourceLocalizer->get($uuid);
21  $ref_uuid = $resource->getUniqueIdentifier();
22  $jobs = [
23  [
24  "id" => substr(str_replace('__', '_', $ref_uuid), 0, -11),
25  "table" => "jobstore_filefetcher_filefetcher",
26  ],
27  [
28  "id" => md5($ref_uuid),
29  "table" => "jobstore_dkan_datastore_importer",
30  ],
31  ];
32 
33  try {
34  foreach ($jobs as $job) {
35  \Drupal::database()->delete($job['table'])->condition('ref_uuid', $job['id'])->execute();
36  $this->logger('datastore')->notice("Successfully removed the {$job['table']} record for ref_uuid {$job['id']}.");
37  }
38  }
39  catch (\Exception $e) {
40  $this->logger('datastore')->error("Failed to delete the jobstore record for ref_uuid {$job['id']}.", $e->getMessage());
41  }
42  }
43 
44 }
Drupal\datastore