@param Job $job

@return array
179404
protected function sendMail(Job $job)
    {

        $mail = $this->getMail();

        $mail->isHTML(true);
        $mail->setFrom($job->getFromMail(), $job->getFromName());
        $mail->addAddress($job->getToMail());

        $mail->Subject = $job->getSubject();
        $mail->Body    = $job->getBody();
        $mail->AltBody = strip_tags($job->getBody());

        $attachments = $job->getAttachment();
        if (!empty($attachments) && is_array($attachments) && count($attachments) > 0) {
            foreach ($attachments as $key => $attach) {
                if(isset($attach[Job::P_PARAM_ATTACHMENT__NAME])){
                    $mail->addAttachment($attach[Job::P_PARAM_ATTACHMENT__PATH] , $attach[Job::P_PARAM_ATTACHMENT__NAME]);
                } else {
                    $mail->addAttachment($attach[Job::P_PARAM_ATTACHMENT__PATH]);
                }
            }
        }

        $isSend = $mail->send();

        return [
            'success' => $isSend
        ];
    }
1309051
protected function createStringPayload($job, $data)
    {
        return [
            'displayName' => is_string($job) ? explode('@', $job)[0] : null,
            'job' => $job, 'maxTries' => null,
            'timeout' => null, 'data' => $data,
        ];
    }
1128411
public function enqueue(Job $job): void
    {
        $this->adapter->enqueue($job);
        $this->updateStatus($job, self::STATUS_WAITING);
    }
567989
public function calculate(Job $job)
    {
        $rootJob = $job->isRoot() ? $job : $job->getRootJob();
        $stopStatuses = [Job::STATUS_SUCCESS, Job::STATUS_FAILED, Job::STATUS_CANCELLED];

        if (in_array($rootJob->getStatus(), $stopStatuses, true)) {
            return;
        }

        $rootStopped = false;
        $this->jobStorage->saveJob($rootJob, function (Job $rootJob) use ($stopStatuses, &$rootStopped) {
            if (in_array($rootJob->getStatus(), $stopStatuses, true)) {
                return;
            }

            $childJobs = $rootJob->getChildJobs();
            if ($childJobs instanceof Collection) {
                $childJobs = $childJobs->toArray();
            }

            $status = $this->calculateRootJobStatus($childJobs);

            $rootJob->setStatus($status);

            if (in_array($status, $stopStatuses, true)) {
                $rootStopped = true;
                if (!$rootJob->getStoppedAt()) {
                    $rootJob->setStoppedAt(new \DateTime());
                }
            }
        });

        return $rootStopped;
    }
33220
protected function extract($job)
    {
        $this->job = $job;
        $this->getJsonLdHelper()->setJob($job);
        $this->setApplyData();
        $this->setOrganizationInfo();
        $this->setLocation();
        $this->setDescription();
        $this->setTemplate();
        $this->setTemplateDefaultValues();

        $this->container['descriptionEditable'] = $job->getTemplateValues()->getDescription();
        $this->container['benefits'] = $job->getTemplateValues()->getBenefits();
        $this->container['requirements'] = $job->getTemplateValues()->getRequirements();
        $this->container['qualifications'] = $job->getTemplateValues()->getQualifications();
        $this->container['title'] = $job->getTemplateValues()->getTitle();
        $this->container['headTitle'] = strip_tags($job->getTemplateValues()->getTitle());
        $this->container['uriApply'] = $this->container['applyData']['uri'];
        $this->container['contactEmail'] = strip_tags($job->getContactEmail());
        $this->container['html'] = $job->getTemplateValues()->getHtml();

        $this->container['jobId'] = $job->getId();
        $this->container['uriJob'] = $this->urlPlugin->fromRoute(
            'lang/jobs/view',
            [],
            [
                'query' => [ 'id' => $job->getId() ],
                'force_canonical' => true
            ]
        );

        return $this;
    }
55432
private function validateDependentJobs(array $dependentJobs, Job $job)
    {
        $result = true;
        foreach ($dependentJobs as $dependentJob) {
            if (!isset($dependentJob['topic'], $dependentJob['message'])) {
                $this->logger->critical(sprintf(
                    'Got invalid dependent job data. job: "%s", dependentJob: "%s"',
                    $job->getId(),
                    JSON::encode($dependentJob)
                ));
                $result = false;
                break;
            }
        }

        return $result;
    }
624309
protected function markJobAsReserved($job)
    {
        $job->attempts = $job->attempts + 1;
        $job->reserved_at = $this->getTime();

        $this->getQueryBuilder()->from($this->table)->where('id', $job->id)->update([
            'reserved_at' => $job->reserved_at,
            'attempts' => $job->attempts,
        ]);

        return $job;
    }
526679
public function delete(JobInterface $job)
    {
        if ($job->isRunOnce()) {
            $this->getCache()->delete(self::CACHE_JOB.get_class($job));
        }
        return $job->getBeanstalkJob()->delete();
    }
447042
public function put($job)
    {
        $job['id'] = $this->redis->incr("job_id_sequence");
        $this->redis->lpush("job_queue", serialize($job));
        return $job['id'];
    }
240402
protected function decode($job)
    {
        $job->payload = json_decode($job->payload);

        $job->retried_by = collect(json_decode($job->retried_by))
                    ->sortByDesc('retried_at')->values();

        return $job;
    }
1007438
protected function pushToChannel(Job $job)
    {
        $channelName = $job->channelName() ? $job->channelName() : static::$defaultChannel;

        $state = $this->channelOrFail($channelName)->push($job, $channelName);

        $job->setState($state);

        return $job;
    }
245089
private function executeJob(Job $job)
    {
        $this->currentJobId = $job->getId();
        $job->setLogger($this->logger);
        $this->logger->notice("Starting job #" . $this->currentJobId);
        
        if (!function_exists('pcntl_fork')) {
            $this->runJob($job);
            return;
        }

        $pid = pcntl_fork();
        if ($pid) {
            pcntl_wait($status);
        } else {
            $this->runJob($job);
            die();
        }
    }
659919
protected function _getJobResult(Job $job)
    {
        $jobHash = spl_object_hash($job);
        if (isset($this->runningJobs[$jobHash])) {
            $jobDir = $this->_getJobDirectory($job);
            if (file_exists("$jobDir/out.serialize")) {
                $data = unserialize(file_get_contents("$jobDir/out.serialize"));

                $jobData = $this->runningJobs[$jobHash];

                $job->setData($data);
                $job->end($jobData);

                // Delete data on this job.
                flock($jobData->lockFile, LOCK_UN);
                fclose($jobData->lockFile);
                $this->rm($jobData->jobDir);

                unset($this->runningJobs[$jobHash]);
                return true;
            } else {
                return false;
            }
        }

        return true;
    }
893780
protected function executeJob(Job $job)
    {
        $job->setStartDate($this->now);

        $command = 'php bin/console campaignchain:job '.$job->getId().' --env='.$this->getContainer()->get(
                'kernel'
            )->getEnvironment();
        $process = new Process($command);

        $this->logger->info('Executing Job with command: '.$command);
        $process->setTimeout($this->timeout);

        try {
            $process->mustRun();

            $this->logger->info('Process ID: '.$process->getPid());

            $job->setPid($process->getPid());
            $this->em->flush();
        } catch (ProcessFailedException $e) {
            $errMsg = 'Process failed: '.$e->getMessage();

            $this->logger->error($errMsg);
            $this->logger->info(self::LOGGER_MSG_END);

            $job->setPid($process->getPid());
            $job->setStatus(Job::STATUS_ERROR);
            $job->setMessage($errMsg);
            $this->em->flush();
        }
    }
977745
protected function createObjectPayload($job, $data)
    {
        $commandName = get_class($job);

        $command = serialize(clone $job);

        return array(
            'job'  => 'Nova\Queue\CallQueuedHandler@call',

            'data' => compact('commandName', 'command'),
        );
    }
473061
public function getReport(JobInterface $job)
    {
        foreach ($this->taskReports as $report) {
            if ($report->getJob() === $job) {
                return $report;
            }
        }

        return null;
    }
958255
private function getParams(JobConfig $jobConfig)
    {
        $config = $jobConfig->getConfig();
        $scrollParams = [
            $this->limitParam => $this->getLimit($jobConfig),
            $this->offsetParam => $this->pointer
        ];

        $config['params'] = array_replace($jobConfig->getParams(), $scrollParams);
        return $config;
    }