/** * {@inheritdoc} */ public function scheduleJob(UUID $executionId, $handlerType, $data, \DateTimeInterface $runAt = NULL) { $id = UUID::createRandom(); $handlerType = (string) $handlerType; $job = new Job($id, $executionId, $handlerType, $data); $job->setRunAt($runAt); $time = $job->getRunAt(); if ($time !== NULL) { $time = $time->getTimestamp(); } $this->engine->getConnection()->insert('#__bpmn_job', ['id' => $job->getId(), 'execution_id' => $job->getExecutionId(), 'handler_type' => $job->getHandlerType(), 'handler_data' => new BinaryData(serialize($job->getHandlerData())), 'created_at' => time(), 'run_at' => $time]); $this->engine->info('Created job <{job}> of type "{handler}" targeting execution <{execution}>', ['job' => (string) $job->getId(), 'handler' => $handlerType, 'execution' => (string) $executionId]); return $this->scheduledJobs[] = $job; }
/** * Create an event subscription entry in the DB. * * @param ProcessEngine $engine * @param Job $job */ protected function createSubscription(ProcessEngine $engine, Job $job = NULL) { $execution = $engine->findExecution($this->executionId); $nodeId = $this->nodeId === NULL ? NULL : $execution->getProcessModel()->findNode($this->nodeId)->getId(); $data = ['id' => UUID::createRandom(), 'execution_id' => $execution->getId(), 'activity_id' => $this->activityId, 'node' => $nodeId, 'process_instance_id' => $execution->getRootExecution()->getId(), 'flags' => $this->getSubscriptionFlag(), 'boundary' => $this->boundaryEvent ? 1 : 0, 'name' => $this->name, 'created_at' => time()]; if ($job !== NULL) { $data['job_id'] = $job->getId(); } $engine->getConnection()->insert('#__bpmn_event_subscription', $data); }