6 use Procrastinator\Job\Job;
7 use Drupal\Core\Database\Connection;
20 if (!$this->validateJobClass($jobClass)) {
21 throw new \Exception(
"Invalid jobType provided: $jobClass");
23 $this->jobClass = $jobClass;
24 $this->setOurSchema();
32 $result = parent::retrieve($id);
33 return $result->job_data;
40 $safeClassName = strtolower(preg_replace(
'/\\\\/',
'_', $this->jobClass));
41 return 'jobstore_' . $safeClassName;
47 private function setOurSchema() {
50 'ref_uuid' => [
'type' =>
'varchar',
'length' => 128,
'not null' => TRUE],
51 'job_data' => [
'type' =>
'text',
'length' => 65535],
54 'ref_uuid' => [
'ref_uuid'],
57 'ref_uuid' => [
'table' =>
'node',
'columns' => [
'uuid' =>
'uuid']],
59 'primary key' => [
'ref_uuid'],
62 $this->setSchema($schema);
68 private function validateJobClass(
string $jobClass): bool {
69 if (is_subclass_of($jobClass, Job::class)) {
80 protected function prepareData(
string $data,
string $id = NULL): array {
81 return [
'ref_uuid' => $id,
'job_data' => $data];