private function getAvatarUrl(Contact $contact, $size) { //Force the default image for gravatars based on non-email values. //This is to avoid a collision of the hash based on address fields with some //random internet user's email address (who might have a photo for an avatar) if ($contact->getEmail()) { $identifier = $contact->getEmail(); $forceDefault = false; } else { $identifier = implode(', ', $contact->getAddresses()); $forceDefault = true; //not an email, so force } $identifier = trim(strtolower($identifier)); $hash = md5($identifier); return 'https://secure.gravatar.com/avatar/' . $hash . '?s=' . $size . '&d=wavatar' . ($forceDefault ? '&f=y' : ''); }
/** * @see \Devture\Component\DBAL\Repository\BaseRepository::hydrateModel() */ protected function hydrateModel(array $data) { $model = new Contact($data); if (isset($data['timePeriodId'])) { $model->setTimePeriod($this->timePeriodRepository->find($data['timePeriodId'])); } if (isset($data['serviceNotificationCommandId'])) { $model->setServiceNotificationCommand($this->commandRepository->find($data['serviceNotificationCommandId'])); } if (isset($data['userId'])) { try { $model->setUser($this->userRepository->find($data['userId'])); } catch (NotFound $e) { //User got deleted or something } } return $model; }
public function canUserManageContact(User $user, Contact $contact) { return $this->canUserDoConfigurationManagement($user) || $contact->getUser() === $user; }
public function findByContact(Contact $contact) { return $this->findBy(array('contactsIds' => $contact->getId())); }