Example #1
0
 public function update(Person $person, $nameFirst, $nameLast)
 {
     $credentialsCollection = $person->getCredentials();
     $credentialsCollection->first();
     $credentials = $credentialsCollection->current();
     $credentials->setNameFirst($nameFirst);
     $credentials->setNameLast($nameLast);
     $this->objectManager->persist($credentials);
     $this->objectManager->flush();
 }
 /**
  * Checks if provided person is the same person who is logged in.
  * Contains somehow tricky logic, for identity, stored in a session
  * is not an instance of Person.
  * See documentation for \Application\Entity\Account class for details.
  * @param Person $person person to check if logged in
  * @return boolean true then and only then $person has the same ID as logged in person
  */
 protected function isMyself(Person $person)
 {
     if ($this->identity() == null) {
         return false;
     }
     if ($myself = $this->identity()->getPerson()) {
         if ($myself == null) {
             return false;
         }
         return $person->getId() == $myself->getId();
     }
     return false;
 }
Example #3
0
 public function addFileToPerson(Person $person, $postFile = [])
 {
     $em = $this->getEntityManager();
     $parts = explode('/', $postFile['type']);
     $public = 'public/';
     $link = 'cache/' . $person->getPersonId() . '.' . end($parts);
     $path = $public . $link;
     $data = file_get_contents($postFile['tmp_name']);
     $resized = $this->resizeImage($data, 300, 300, $path);
     $file = $person->getFile() ?: new File();
     $file->setData($resized)->setMimetype($postFile['type']);
     $em->persist($file);
     $person->setFile($file);
     $em->persist($person);
     $em->flush();
 }
Example #4
0
 public function destroy(Person $source, $idOfContact)
 {
     $contact = $this->retrieve($idOfContact);
     if ($source->getContacts()->contains($contact)) {
         $this->objectManager->remove($contact);
         /*
          * Note: Reflected contact might not be needed for other types of contacts.
          * TODO Implement DQL query for handling deletion of bidirectional contacts.
          */
         foreach ($contact->getTarget()->getContacts() as $reflectedContact) {
             if ($reflectedContact->getTarget()->getId() == $source->getId()) {
                 $this->objectManager->remove($reflectedContact);
             }
         }
         $this->objectManager->flush();
     }
 }
 public function addAction()
 {
     $form = new OenologistForm();
     $form->get('submit')->setValue('Add');
     //Populate Country DropDown
     $idcountryOptions = array();
     foreach ($this->getCountrySelectData() as $country) {
         $idcountryOptions[$country->getIdcountry()] = $country->getName();
     }
     $form->get('idcountry')->setAttribute('options', $idcountryOptions);
     // CSS
     $form->get('firstname')->setAttribute('class', 'form-control');
     $form->get('firstname')->setAttribute('placeholder', 'Ej.: Manuel');
     $form->get('lastname')->setAttribute('class', 'form-control');
     $form->get('lastname')->setAttribute('placeholder', 'Ej.: Vivar');
     $form->get('idcountry')->setAttribute('class', 'form-control');
     $form->get('genre')->setAttribute('class', 'form-control');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $person = new Person();
         $oenologist = new Oenologist();
         $form->setInputFilter($person->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             //Save Person first
             $person->exchangeArray($form->getData());
             $person->setIdcountry($this->getEntityManager()->find('Application\\Entity\\Country', $request->getPost('idcountry')));
             $this->getEntityManager()->persist($person);
             $this->getEntityManager()->flush();
             //Save Oenologist then
             $oenologist->setDisabled($request->getPost('disabled'));
             $oenologist->setIdperson($person);
             $this->getEntityManager()->persist($oenologist);
             $this->getEntityManager()->flush();
             // Redirect to Country List
             return $this->redirect()->toRoute('oenologist');
         }
     }
     return array('form' => $form);
 }
Example #6
0
 public function __invoke(\Application\Entity\Person $person, \Admin\Service\FileService $fileService, $imgClass = 'img-circle img-thumbnail img-sm')
 {
     if ($person->getFile()) {
         if (!file_exists('public/' . $person->parseFilePath())) {
             $file = $person->getFile();
             $data = $file->getData();
             $fileService->resizeImage(stream_get_contents($data), 200, 200, 'public/' . $person->parseFilePath());
         }
         return "<img class='" . $imgClass . "' src='" . $person->parseFilePath() . "' />";
     } else {
         $gender = $person->getGender()->getName();
         return '<i class="fa fa-' . strtolower($gender) . ' fa-4x"></i>';
     }
 }
 /**
  * {@inheritDoc}
  */
 public function getEmailAddresses()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getEmailAddresses', array());
     return parent::getEmailAddresses();
 }
 /**
  * {@inheritDoc}
  */
 public function getFullName($mode = NULL)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getFullName', array($mode));
     return parent::getFullName($mode);
 }