/** * AddAffiliation constructor. * * @param OrganisationService $organisationService * @param ProjectService $projectService */ public function __construct(OrganisationService $organisationService, ProjectService $projectService) { parent::__construct(); $currentProjects = []; /** * @var $projectService ProjectService */ foreach ($projectService->findProjectByOrganisation($organisationService->getOrganisation(), ProjectService::WHICH_ALL) as $projectService) { $currentProjects[] = $projectService->getProject()->getId(); } $projects = []; /** * @var $newProjectService ProjectService */ foreach ($projectService->findAllProjects(ProjectService::WHICH_ALL)->getResult() as $newProject) { if (!in_array($newProject->getId(), $currentProjects)) { $projects[$newProject->getId()] = sprintf("%s", $newProject); } } arsort($projects); $this->add(['type' => 'Zend\\Form\\Element\\Select', 'name' => 'project', 'options' => ['value_options' => $projects, 'help-block' => _("txt-project-help-block")], 'attributes' => ['label' => _("txt-project")]]); $this->add(['type' => 'Zend\\Form\\Element\\Text', 'name' => 'branch', 'options' => ['help-block' => _("txt-branch-help-block")], 'attributes' => ['label' => _("txt-branch")]]); $contacts = []; foreach ($organisationService->getOrganisation()->getContactOrganisation() as $contactOrganisation) { $contacts[$contactOrganisation->getContact()->getId()] = $contactOrganisation->getContact()->getFormName(); } asort($contacts); $this->add(['type' => 'Zend\\Form\\Element\\Select', 'name' => 'contact', 'options' => ['value_options' => $contacts, 'help-block' => _("txt-technical-contact-help-block")], 'attributes' => ['label' => _("txt-technical-contact")]]); $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'submit', 'attributes' => ['class' => "btn btn-primary", 'value' => _("txt-submit")]]); $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'cancel', 'attributes' => ['class' => "btn btn-warning", 'value' => _("txt-cancel")]]); }
/** * @param Contact $object * * @return array */ public function extract($object) { $this->prepare($object); $values = $this->extractByValue($object); unset($values['phone']); foreach ($object->getPhone() as $phone) { $values['phone'][$phone->getType()->getId()]['phone'] = $phone->getPhone(); } unset($values['address']); foreach ($object->getAddress() as $address) { if ($address->getType()->getId() === AddressType::ADDRESS_TYPE_MAIL) { $values['address']['address'] = $address->getAddress(); $values['address']['zipCode'] = $address->getZipCode(); $values['address']['city'] = $address->getCity(); $values['address']['country'] = $address->getCountry(); } } unset($values['profile']); $values['profile']['visible'] = !is_null($object->getProfile()) ? $object->getProfile()->getVisible() : null; $values['profile']['description'] = !is_null($object->getProfile()) ? $object->getProfile()->getDescription() : null; /* * Set the contact organisation, this will be taken from the contact_organisation item and can be used * to pre-fill the values */ $contactService = new ContactService(); $contactService->setContact($object); if (!is_null($object->getContactOrganisation())) { $organisationService = new OrganisationService(); $organisationService->setOrganisation($object->getContactOrganisation()->getOrganisation()); $values['contact_organisation']['organisation_id'] = $organisationService->getOrganisation()->getId(); $values['contact_organisation']['organisation'] = $organisationService->parseOrganisationWithBranch($contactService->getContact()->getContactOrganisation()->getBranch()); if (!is_null($object->getContactOrganisation())) { $values['contact_organisation']['country'] = $object->getContactOrganisation()->getOrganisation()->getCountry()->getId(); } } return $values; }
/** * @param OrganisationService $organisationService * * @return \Content\Entity\Article[] */ public function parseOrganisationArticleList(OrganisationService $organisationService) { $articles = $this->getArticleService()->findArticlesByOrganisation($organisationService->getOrganisation(), $this->getLimit()); /* * Parse the organisationService in to have the these functions available in the view */ return $this->getRenderer()->render('organisation/partial/list/article', ['organisationService' => $organisationService, 'articles' => $articles, 'limit' => $this->getLimit()]); }