/** * {@inheritdoc} */ public function convertItem($user) { $result = parent::convertItem($user); $result['avatar'] = null; $avatar = $this->getPropertyValue('avatar', $user); if ($avatar) { $result['avatar'] = $this->attachmentManager->getFilteredImageUrl($avatar, self::IMAGINE_AVATAR_FILTER); } return $result; }
public function testGetFilteredImageUrl() { $this->attachment->setId(1); $filerName = 'testFilter'; $this->attachment->setOriginalFilename('test.doc'); $this->router->expects($this->once())->method('generate')->with('oro_filtered_attachment', ['id' => 1, 'filename' => 'test.doc', 'filter' => $filerName]); $this->attachmentManager->getFilteredImageUrl($this->attachment, $filerName); }
/** * @param $user * * @return string|null */ protected function getUserAvatar($user) { $avatar = $this->getPropertyValue('avatar', $user); if (!$avatar) { return null; } return $this->attachmentManager->getFilteredImageUrl($avatar, UserSearchHandler::IMAGINE_AVATAR_FILTER); }
/** * @param array $result * @param string $attrName * @param User $user */ protected function addUser(array &$result, $attrName, $user) { if ($user) { $result[$attrName] = $this->nameFormatter->format($user); $result[$attrName . '_id'] = $user->getId(); $result[$attrName . '_viewable'] = $this->securityFacade->isGranted('VIEW', $user); $avatar = $user->getAvatar(); $result[$attrName . '_avatar'] = $avatar ? $this->attachmentManager->getFilteredImageUrl($avatar, 'avatar_xsmall') : null; } }
/** * @param User $user * @return UserDetails */ public function fetchUserDetails(User $user) { $loadedUser = $this->getByUser($user); if (!$loadedUser) { throw new \RuntimeException('Failed to load details for given user'); } $userAvatarUrl = null; if ($user->getType() == User::TYPE_ORO) { if ($loadedUser->getAvatar()) { $originalFilename = $loadedUser->getAvatar()->getOriginalFilename(); if (!empty($originalFilename)) { $userAvatarUrl = $this->attachmentManager->getFilteredImageUrl($loadedUser->getAvatar(), 'avatar_med'); } } } return new UserDetails((string) $user, $user->getType(), $loadedUser->getEmail(), $loadedUser->getFirstName(), $loadedUser->getLastName(), $userAvatarUrl); }
/** * {@inheritdoc} */ public function convertItem($user) { $result = []; foreach ($this->fields as $field) { $result[$field] = $this->getPropertyValue($field, $user); } $result['avatar'] = null; $avatar = $this->getPropertyValue('avatar', $user); if ($avatar) { $result['avatar'] = $this->attachmentManager->getFilteredImageUrl($avatar, UserSearchHandler::IMAGINE_AVATAR_FILTER); } if (!$this->nameFormatter) { throw new \RuntimeException('Name formatter must be configured'); } $result['fullName'] = $this->nameFormatter->format($user); return $result; }
/** * @param User $user * @return array */ protected function createUserView(User $user) { return ['id' => $user->getId(), 'url' => $this->router->generate('oro_user_view', array('id' => $user->getId())), 'fullName' => $this->entityNameResolver->getName($user), 'avatar' => $user->getAvatar() ? $this->attachmentManager->getFilteredImageUrl($user->getAvatar(), 'avatar_xsmall') : null, 'permissions' => array('view' => $this->securityFacade->isGranted('VIEW', $user))]; }
/** * @param File $attachment * @param string $filterName * @return string */ public function getFilteredImageUrl(File $attachment, $filterName) { return $this->manager->getFilteredImageUrl($attachment, $filterName); }
/** * @param User $user * @return null|string */ public function getUserAvatar(User $user) { return $user->getAvatar() ? $this->attachmentManager->getFilteredImageUrl($user->getAvatar(), 'avatar_xsmall') : null; }