protected function save() { $userId = $this->params()->fromPost('userId'); $org = $this->job->getOrganization(); if ($org->isHiringOrganization()) { $org = $org->getParent(); } /* * Maybe we should inject the user repository also, to prevent this * rather expensive loop. On the other hand... how often will someone change the job user? */ if ($org->getUser()->getId() == $userId) { $this->job->setUser($org->getUser()); } else { /* @var \Organizations\Entity\Employee $emp */ foreach ($org->getEmployees() as $emp) { $user = $emp->getUser(); if ($user->getId() == $userId) { $this->job->setUser($user); } } } $model = new JsonModel(array('success' => true)); return $model; }
/** * @param Job $job * @return array */ public function dehydrate(Job $job) { return array('title' => $job->getTitle(), 'location' => $job->getLocation(), 'link' => $this->url->__invoke('lang/jobs/view', [], ['query' => ['id' => $job->getId()], 'force_canonical' => true]), 'organization' => array('name' => $job->getOrganization()->getOrganizationName()->getName()), 'template_values' => array('requirements' => $job->getTemplateValues()->getRequirements(), 'qualification' => $job->getTemplateValues()->getQualifications(), 'benefits' => $job->getTemplateValues()->getBenefits())); }