/** * @param JobInterface $job * @return string */ protected function getJobStatusLabel(JobInterface $job) { /** @var \WeavingTheWeb\Bundle\ApiBundle\Entity\Job $job */ $status = $job->getStatus(); $jobReflection = new \ReflectionClass($job); $constants = $jobReflection->getConstants(); $statuses = array_flip($constants); $statusConstantName = $statuses[$status]; return strtolower(str_replace(Job::PREFIX_STATUS, '', $statusConstantName)); }
/** * @param JobInterface $job */ protected function isGrantedJobAccess(JobInterface $job) { if (!$job instanceof UserAwareInterface) { throw new AccessDeniedHttpException(); } $jobUser = $job->getUser(); $currentUser = $this->tokenStorage->getToken()->getUser(); if (!$jobUser instanceof EquatableInterface) { throw new AccessDeniedHttpException(); } if (!$jobUser->isEqualTo($currentUser)) { throw new AccessDeniedHttpException(); } }