Пример #1
0
 /**
  * @Route("/settings/image")
  * @Template()
  * @Method("POST")
  * @Security("has_role('ROLE_USER')")
  */
 public function updateImageAction()
 {
     $user = $this->getUser();
     $em = $this->getDoctrine()->getManager();
     $company = $this->getUser()->getCompany();
     $request = $this->getRequest();
     if ($imageFile = $request->files->get('image')) {
         $image = new Image($imageFile, array('256'), 'companies/images', $this->container);
         $company->setImageUrl($image->getPaths('256'));
     }
     $em->flush();
     $this->get('session')->getFlashBag()->add('notice', 'Your changes were saved!');
     return $this->redirect($this->generateUrl('ui_company'));
 }
Пример #2
0
 /**
  * @Route("/buddy/{hash}/image")
  * @Template()
  * @Method("POST")
  * @Security("has_role('ROLE_USER')")
  */
 public function updateImageAction($hash)
 {
     $user = $this->getUser();
     $em = $this->getDoctrine()->getManager();
     $employee = $em->getRepository('VoIPCompanyStructureBundle:Employee')->findOneBy(array('hash' => $hash));
     if (!$employee) {
         throw $this->createNotFoundException('Unable to find Employee entity.');
     }
     $company = $employee->getCompany();
     if ($user->getCompany()->getId() != $company->getId()) {
         throw $this->createNotFoundException('No authorization.');
     }
     $request = $this->getRequest();
     if ($imageFile = $request->files->get('image')) {
         $image = new Image($imageFile, array('64', '256'), 'buddies/images', $this->container);
         $employee->setImageUrl($image->getPaths('256'));
         $employee->setThumbUrl($image->getPaths('64'));
     }
     $em->flush();
     $this->get('session')->getFlashBag()->add('notice', 'Your changes were saved!');
     return $this->redirect($this->generateUrl('ui_company'));
 }