/**
  * @param User $item
  * @return array
  */
 protected function convertItemFromObject(User $item)
 {
     $converted = array();
     $obj = $this->userService->fetchUserDetails($item);
     $converted[self::ID_FIELD_NAME] = $obj->getId();
     foreach ($this->properties as $property) {
         $converted[$property] = $this->getPropertyValue($property, $obj);
     }
     if (empty($converted['fullName']) || $converted['fullName'] === ' ') {
         $converted['fullName'] = $converted['email'];
     }
     if ($item->isDiamanteUser()) {
         $realUserObj = $this->userService->getByUser($item);
         $converted['isDeleted'] = $realUserObj->isDeleted();
     } else {
         $converted['isDeleted'] = false;
     }
     $converted['type'] = $item->getType();
     if ($item->getType() === User::TYPE_DIAMANTE) {
         $converted['type_label'] = 'customer';
     } else {
         $converted['type_label'] = 'admin';
     }
     return $converted;
 }
 /**
  * @param User $user
  * @return string
  */
 public function renderUserName(User $user)
 {
     $userDetails = $this->userService->fetchUserDetails($user);
     if ($userDetails->getFirstName() || $userDetails->getLastName()) {
         return $userDetails->getFullName();
     } else {
         return $userDetails->getEmail();
     }
 }
 /**
  * Retrieves Person (Provider or Assignee) Data based on typed ID provided
  *
  * @ApiDoc(
  *  description="Returns person data",
  *  uri="/ticket/{id}/assignee.{_format}",
  *  method="GET",
  *  resource=true,
  *  requirements={
  *       {
  *           "name"="id",
  *           "dataType"="integer",
  *           "requirement"="\d+",
  *           "description"="Ticket Id"
  *       }
  *   },
  *  statusCodes={
  *      200="Returned when successful",
  *      403="Returned when the user is not authorized to view tickets"
  *  }
  * )
  *
  * @param $id
  * @return array
  */
 public function getAssigneeForTicket($id)
 {
     $ticket = $this->loadTicket($id);
     $assignee = $ticket->getAssignee();
     $details = [];
     if (!empty($assignee)) {
         $assigneeAdapter = new User($assignee->getId(), User::TYPE_ORO);
         $details = $this->userService->fetchUserDetails($assigneeAdapter);
     }
     return $details;
 }
 /**
  * @param Notification $notification
  * @return \ArrayAccess
  */
 private function postProcessChangesList(Notification $notification)
 {
     $changes = $notification->getChangeList();
     if (isset($changes['Reporter']) && strpos($changes['Reporter'], '_')) {
         $r = $changes['Reporter'];
         $u = User::fromString($r);
         $details = $this->userService->fetchUserDetails($u);
         $changes['Reporter'] = $details->getFullName();
     }
     return $changes;
 }
 /**
  * @param User $item
  * @return array
  */
 protected function convertItemFromObject(User $item)
 {
     $converted = array();
     $obj = $this->userService->fetchUserDetails($item);
     $converted[self::ID_FIELD_NAME] = $obj->getId();
     foreach ($this->properties as $property) {
         $converted[$property] = $this->getPropertyValue($property, $obj);
     }
     if (empty($converted['fullName']) || $converted['fullName'] === ' ') {
         $converted['fullName'] = $converted['email'];
     }
     return $converted;
 }
 /**
  * @param Comment $comment
  * @return array
  */
 private function getCommentData(Comment $comment)
 {
     $data = ['attachments' => $comment->getAttachments(), 'content' => $comment->getContent(), 'created_at' => $comment->getCreatedAt(), 'updated_at' => $comment->getUpdatedAt(), 'id' => $comment->getId(), 'private' => $comment->isPrivate(), 'ticket' => $comment->getTicketId(), 'author' => $this->userService->fetchUserDetails($comment->getAuthor())];
     return $data;
 }
 /**
  * Retrieves comment author data based on typed ID provided
  *
  * @ApiDoc(
  *  description="Returns person data",
  *  uri="/comment/{id}/author.{_format}",
  *  method="GET",
  *  resource=true,
  *  requirements={
  *       {
  *           "name"="id",
  *           "dataType"="integer",
  *           "requirement"="\d+",
  *           "description"="Author Id"
  *       }
  *   },
  *  statusCodes={
  *      200="Returned when successful",
  *      403="Returned when the user is not authorized to view tickets"
  *  }
  * )
  *
  * @param $id
  * @return array
  */
 public function getAuthorData($id)
 {
     $comment = $this->loadComment($id);
     $details = $this->userService->fetchUserDetails($comment->getAuthor());
     return $details;
 }