public function indexAction() { $organizationId = $this->params()->fromRoute('organizationId', 0); try { $jobs = $this->jobRepository->findByOrganization($organizationId); } catch (\Exception $e) { /** @var Response $response */ $response = $this->getResponse(); $response->setStatusCode(Response::STATUS_CODE_404); return $response; } $jsonModel = new JsonModel(); $jsonModel->setVariables($this->apiJobDehydrator->dehydrateList($jobs)); $jsonModel->setJsonpCallback('yawikParseJobs'); return $jsonModel; }
/** * Handles the job opening template in formular mode * * @return ViewModel */ protected function editTemplateAction() { $id = $this->params('id'); $formIdentifier = $this->params()->fromQuery('form'); $job = $this->jobRepository->find($id); $request = $this->getRequest(); $isAjax = $request->isXmlHttpRequest(); $services = $this->getServiceLocator(); $viewHelperManager = $services->get('ViewHelperManager'); $mvcEvent = $this->getEvent(); $applicationViewModel = $mvcEvent->getViewModel(); $model = new ViewModel(); $forms = $services->get('FormElementManager'); /** @var \Jobs\Form\JobDescriptionTemplate $formTemplate */ $formTemplate = $forms->get('Jobs/Description/Template', array('mode' => $job->id ? 'edit' : 'new')); $formTemplate->setParam('id', $job->id); $formTemplate->setParam('applyId', $job->applyId); $formTemplate->setEntity($job); if (isset($formIdentifier) && $request->isPost()) { // at this point the form get instanciated and immediately accumulated $instanceForm = $formTemplate->get($formIdentifier); if (!isset($instanceForm)) { throw new \RuntimeException('No form found for "' . $formIdentifier . '"'); } // the id is part of the postData, but it never should be altered $postData = $request->getPost(); unset($postData['id']); unset($postData['applyId']); $instanceForm->setData($postData); if ($instanceForm->isValid()) { $this->getServiceLocator()->get('repositories')->persist($job); } } if (!$isAjax) { $basePath = $viewHelperManager->get('basepath'); $headScript = $viewHelperManager->get('headscript'); $headScript->appendFile($basePath->__invoke('/Core/js/core.forms.js')); } else { return new JsonModel(array('valid' => True)); } $model->setTemplate('templates/' . $job->template . '/index'); $applicationViewModel->setTemplate('iframe/iFrameInjection'); $model->setVariables($this->getTemplateFields($job, $formTemplate)); return $model; }
/** * Action hook for Job search bar in list filter. * * @return JsonModel */ public function typeaheadAction() { $query = $this->params()->fromQuery('q', '*'); $return = array(); foreach ($this->jobRepository->getTypeaheadResults($query, $this->auth('id')) as $id => $item) { $return[] = array('id' => $id, 'title' => $item['title'], 'applyId' => $item['applyId']); } return new JsonModel($return); }
/** * Handles the job opening template in formular mode. * * All template forms are sending the ID of a job posting and an identifier of the sending * form. * * @return ViewModel */ protected function editTemplateAction() { $id = $this->params('id'); $formIdentifier = $this->params()->fromQuery('form'); $job = $this->jobRepository->find($id); $this->acl($job, 'edit'); /** @var \Zend\Http\Request $request */ $request = $this->getRequest(); $isAjax = $request->isXmlHttpRequest(); $services = $this->serviceLocator; $viewHelperManager = $services->get('ViewHelperManager'); $mvcEvent = $this->getEvent(); $applicationViewModel = $mvcEvent->getViewModel(); $forms = $services->get('FormElementManager'); /** @var \Jobs\Form\JobDescriptionTemplate $formTemplate */ $formTemplate = $forms->get('Jobs/Description/Template', array('mode' => $job->id ? 'edit' : 'new')); $formTemplate->setParam('id', $job->id); $formTemplate->setParam('applyId', $job->applyId); $formTemplate->setEntity($job); if (isset($formIdentifier) && $request->isPost()) { // at this point the form get instantiated and immediately accumulated $instanceForm = $formTemplate->get($formIdentifier); if (!isset($instanceForm)) { throw new \RuntimeException('No form found for "' . $formIdentifier . '"'); } // the id is part of the postData, but it never should be altered $postData = $request->getPost(); unset($postData['id']); unset($postData['applyId']); $instanceForm->setData($postData); if ($instanceForm->isValid()) { $this->serviceLocator->get('repositories')->persist($job); } } $model = $services->get('Jobs/ViewModelTemplateFilter')->__invoke($formTemplate); if (!$isAjax) { $basePath = $viewHelperManager->get('basepath'); $headScript = $viewHelperManager->get('headscript'); $headScript->appendFile($basePath->__invoke('/Core/js/core.forms.js')); $headStyle = $viewHelperManager->get('headstyle'); $headStyle->prependStyle('form > input { color: inherit !important; margin:inherit !important; padding:inherit !important; border:0 !important; cursor:pointer !important; letter-spacing:inherit !important; line-height: inherit !important; font-size: inherit !important; } '); } else { return new JsonModel(array('valid' => true)); } $applicationViewModel->setTemplate('iframe/iFrameInjection'); return $model; }
public function testFindActiveJob() { $jobs = $this->repository->findActiveJob(); $this->assertInstanceOf(Cursor::class, $jobs); $this->assertCount(5, $jobs); }
/** * @see \Auth\Dependency\ListInterface::getEntities() */ public function getEntities(User $user) { return $this->repository->getUserJobs($user->getId()); }