@param string $ownerId
@param string $jobName

@return Job
482794
public function findRootJobByOwnerIdAndJobName($ownerId, $jobName)
    {
        $qb = $this->getEntityRepository()->createQueryBuilder('job');

        return $qb
            ->where('job.ownerId = :ownerId AND job.name = :jobName')
            ->setParameters([
                'ownerId' => $ownerId,
                'jobName' => $jobName,
            ])
            ->getQuery()->getOneOrNullResult()
        ;
    }
221257
public function generateTableName($ownerTableName, $tableNameSuffix)
    {
        if (preg_match('/{{%(\w+)}}$/', $ownerTableName, $matches)) {
            $ownerTableName = $matches[1];
        }

        return '{{%' . $ownerTableName . $tableNameSuffix . '}}';
    }
958706
public function createJob(Job $job)
	{
		$url = $this->service_url . '/jobs';
		$data = $this->service->prepAndSend($url, array(201, 200), 'PUT', $job->toJSON(), true, 'application/job+json', 'application/job+json');
        return Job::createFromJSON(json_decode($data));
	}
958228
public function findOrCreateChildJob($jobName, Job $rootJob)
    {
        if (!$jobName) {
            throw new \LogicException('Job name must not be empty');
        }

        $rootJob = $this->jobStorage->findJobById($rootJob->getId());
        $job = $this->jobStorage->findChildJobByName($jobName, $rootJob);

        if ($job) {
            return $job;
        }

        $job = $this->jobStorage->createJob();
        $job->setStatus(Job::STATUS_NEW);
        $job->setName($jobName);
        $job->setCreatedAt(new \DateTime());
        $job->setRootJob($rootJob);

        $this->saveJob($job);

        $this->sendCalculateRootJobStatusEvent($job);

        return $job;
    }
554341
public function viewBlockAction($owner, $ownerId, $id)
    {
        /** @var BlockManager $manager */
        $manager = $this->get('opifer.content.block_manager');

        $object = $this->get('opifer.content.block_provider_pool')->getProvider($owner)->getBlockOwner($ownerId);

        /** @var Environment $environment */
        $environment = $this->get('opifer.content.block_environment');
        $environment->setDraft(true)->setObject($object);

        $block = $environment->getBlock($id);

        $environment->setBlockMode(Environment::MODE_MANAGE);

        /** @var AbstractBlockService $service */
        $service = $manager->getService($block);
        $service->setEnvironment($environment);

        $this->get('opifer.content.twig.content_extension')->setBlockEnvironment($environment);


        return new JsonResponse(['view' => $service->manage($block)->getContent()]);
    }
28557
public function addOwner($owner_id, $owner, $owner_attribute)
    {
        $mediafiles = new Owners();
        $mediafiles->mediafile_id = $this->id;
        $mediafiles->owner = $owner;
        $mediafiles->owner_id = $owner_id;
        $mediafiles->owner_attribute = $owner_attribute;

        return $mediafiles->save();
    }
1222728
public function addUserToProject($writerId, $pid, $email, $role = 'editor', $queue = 'primary')
    {
        $job = $this->addUserToProjectAsync($writerId, $pid, $email, $role, $queue);
        if (!isset($job['url'])) {
            throw new ServerException('Create project job returned unexpected result: ' . json_encode($job, JSON_PRETTY_PRINT));
        }

        return $this->waitForJob($job['url']);
    }
255509
public function findOrganizationJob($organizationId, $jobId)
    {
        list($response) = $this->findOrganizationJobWithHttpInfo($organizationId, $jobId);
        return $response;
    }
727600
public function findRootJobByJobNameAndStatuses($jobName, array $statuses)
    {
        return $this->createJobQueryBuilder('job')
            ->where('job.rootJob is NULL and job.name = :jobName and job.status in (:statuses)')
            ->andWhere('job.interrupted != true')
            ->setParameter('jobName', $jobName)
            ->setParameter('statuses', $statuses)
            ->setMaxResults(1)
            ->getQuery()
            ->getOneOrNullResult();
    }
1073252
public function runDelayed($jobId, \Closure $runCallback)
    {
        $job = $this->jobProcessor->findJobById($jobId);
        if (! $job) {
            throw JobNotFoundException::create($jobId);
        }
        $this->throwIfJobIsStale($job);

        if ($job->getRootJob()->isInterrupted()) {
            if (! $job->getStoppedAt()) {
                $this->jobProcessor->cancelChildJob($job);
            }

            return null;
        }

        $this->jobExtension->onPreRunDelayed($job);

        if ($this->isReadyForStart($job)) {
            $this->jobProcessor->startChildJob($job);
        }

        $result = $this->callbackResult($runCallback, $job);

        if (! $job->getStoppedAt()) {
            $result
                ? $this->jobProcessor->successChildJob($job)
                : $this->jobProcessor->failChildJob($job);
        }

        $this->jobExtension->onPostRunDelayed($job, $result);

        return $result;
    }
319451
public function findChildJobByName($name, Job $rootJob)
    {
        $qb = $this->getEntityRepository()->createQueryBuilder('job');

        return $qb
            ->addSelect('rootJob')
            ->leftJoin('job.rootJob', 'rootJob')
            ->where('rootJob = :rootJob AND job.name = :name')
            ->setParameter('rootJob', $rootJob)
            ->setParameter('name', $name)
            ->getQuery()->getOneOrNullResult()
        ;
    }
1185161
public function getJob($jobName)
    {
        $jobName = $this->jobPrefix . $jobName;

        foreach ($this->workers as $worker) {

            if (is_array($worker['jobs'])) {

                foreach ($worker['jobs'] as $job) {

                    if ($jobName === $job['realCallableName']) {

                        $worker['job'] = $job;

                        return $worker;
                    }
                }
            }
        }

        throw new JobDoesNotExistException();
    }
121051
public function call(Job $job, array $data)
    {
        try {
            $command = $this->setJobInstanceIfNecessary(
                $job, unserialize($data['command'])
            );
        } catch (ModelNotFoundException $e) {
            return $this->handleModelNotFound($job, $e);
        }

        $this->dispatcher->dispatchNow(
            $command, $this->resolveHandler($job, $command)
        );

        if (! $job->hasFailed() && ! $job->isReleased()) {
            $this->ensureNextJobInChainIsDispatched($command);
        }

        if (! $job->isDeletedOrReleased()) {
            $job->delete();
        }
    }
397305
public function findJobById($id)
    {
        return $this->createJobQueryBuilder('job')
            ->addSelect('rootJob')
            ->leftJoin('job.rootJob', 'rootJob')
            ->where('job = :id')
            ->setParameter('id', $id)
            ->getQuery()
            ->getOneOrNullResult();
    }
307717
public function release_lock($key, $ownerid) {
        if ($this->check_lock_state($key, $ownerid)) {
            return ($this->redis->del($key) !== false);
        }
        return false;
    }
425216
public function getEmployee($employeeId)
    {
        $result = null;
        $this->addHeader();
        try {
            $employee = $this->getSoap()->GetAcsEmployee([
                'id' => $employeeId
            ]);
            if (isset($employee->GetAcsEmployeeResult)) {
                $result = new Employee((array)$employee->GetAcsEmployeeResult);
            }
        } catch (\SoapFault $ex) {
            $result = false;
            $this->logError();
        }
        return $result;
    }
1024733
public function createJob($serverId, array $data, $wait = true)
    {
        $job = $this->post("servers/$serverId/jobs", $data)['job'];

        if ($wait) {
            return $this->retry($this->getTimeout(), function () use ($serverId, $job) {
                $job = $this->job($serverId, $job['id']);

                return $job->status == 'installed' ? $job : null;
            });
        }

        return new Job($job + ['server_id' => $serverId], $this);
    }