Exemplo n.º 1
0
 /**
  * @Route("/customer/{platformid}/{organizationid}/edit", name="_organization_edit", requirements={
  *     "platformid": "([a-z0-9]{8})(\-[a-z0-9]{4}){3}(\-[a-z0-9]{12})",
  *     "organizationid": "([a-z0-9]{8})(\-[a-z0-9]{4}){3}(\-[a-z0-9]{12})"
  * })
  */
 public function editAction(Request $request, $platformid, $organizationid)
 {
     $platform_repository = (new PlatformPeer())->getLdapManager()->getRepository('platform');
     $platform = $platform_repository->getPlatformByUUID($platformid);
     $organizationPeer = new OrganizationPeer($platform->getDn());
     $organization_repository = $organizationPeer->getLdapManager()->getRepository('organization');
     $organizationLdap = $organization_repository->getOrganizationByUUID($organizationid);
     $tranformer = new ZacaciaTransformer();
     $organization = $tranformer->transOrganization($organizationLdap);
     $form = $this->createForm(OrganizationType::class, $organization);
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         try {
             $organizationLdap->setZarafaHidden($organization->getZarafaHidden());
             $organizationLdap->setZarafaAccount($organization->getZarafaAccount());
             $organizationLdap->setZacaciastatus($organization->getZacaciastatus());
             $organizationPeer->updateOrganization($organizationLdap);
             return $this->redirectToRoute('_organization', array('platformid' => $platform->getEntryUUID()));
         } catch (LdapConnectionException $e) {
             echo "Failed to update organization!" . PHP_EOL;
             echo $e->getMessage() . PHP_EOL;
         }
     }
     return $this->render('ZacaciaBundle:Organization:edit.html.twig', array('platform' => $platform, 'organization' => $organization, 'form' => $form->createView()));
 }