/** * @Security("has_role('ROLE_USER')") * @Route("/user/get-conversations", name="user-get-conversations", options={"expose"=true}) * @return JsonResponse */ public function getConversationsAction() { /** @var User $user */ $user = $this->getUser(); /** @var EntityManager $em */ $em = $this->getDoctrine()->getManager(); $conversations = Conversation::getConversationsByUser($em, $user->getId()); return new JsonResponse(Functions::arrayToJsonSingle($conversations, $user)); }
/** * @param \Exception $ex * @param string $from */ public function registerException(\Exception $ex, $from) { $this->em = Functions::getEntityManager($this->em); $error = new ErrorLog(); $error->setMessage($ex->getMessage()); $error->setWhereError('File: ' . $ex->getFile() . ', Line: ' . $ex->getLine()); $error->setFromError($from); $this->em->persist($error); $this->em->flush(); }
/** * @Security("has_role('ROLE_USER')") * @Route("/user/get/cabinet-profile", name="get-cabinet-profile", options={"expose"=true}) * @return JsonResponse */ public function getCabinetProfileAction() { /** @var User $user */ $user = $this->getUser(); /** @var EntityManager $em */ $em = $this->getDoctrine()->getManager(); $advs = $em->getRepository('NaidusvoeBundle:Advertisment')->findBy(['userID' => $user->getId()], null, 6); return new JsonResponse(['user' => $user->getInArray(), 'advs' => Functions::arrayToJson($advs)], 200); }
public function getInArrayWithoutParent() { return array('id' => $this->getId(), 'typeID' => $this->getTypeID(), 'name' => $this->getName(), 'subCategories' => Functions::arrayToJson($this->getSubCategories())); }
public function getInArray() { $onMain = $this->getOnMainUntill(); $onTop = $this->getOnTopUntill(); $filled = $this->getFilledUntill(); $urgent = $this->getUrgentUntill(); $block = $this->getOnBlockUntill(); return array('id' => $this->getId(), 'title' => $this->getTitle(), 'description' => $this->getDescription(), 'type' => $this->getType()->getInArraySingle(), 'category' => !$this->dummy ? $this->getCategory()->getInArraySingle() : null, 'subCategory' => $this->getSubCategory() ? $this->getSubCategory()->getInArray() : null, 'attachments' => Functions::arrayToJson($this->getAttachments()), 'userID' => $this->getUserID(), 'price' => $this->getPrice(), 'priceType' => !$this->dummy ? $this->getPriceType()->getInArray() : null, 'contactPerson' => $this->getContactPerson(), 'email' => $this->getEmail(), 'telephoneNumber' => $this->getTelephoneNumber(), 'skype' => $this->getSkype(), 'city' => $this->city, 'region' => !$this->dummy ? $this->region->getInArray() : null, 'date' => $this->date->format('m.d.Y'), 'time' => $this->date->format('H:i:s'), 'dummy' => $this->dummy, 'onMain' => $onMain !== null ? $onMain->format('d.m.Y') : null, 'onTop' => $onTop !== null ? $onTop->format('d.m.Y') : null, 'filled' => $filled !== null ? $filled->format('d.m.Y') : null, 'urgent' => $urgent !== null ? $urgent->format('d.m.Y') : null, 'block' => $block !== null ? $block->format('d.m.Y') : null); }
/** * @param User $user * @return array */ public function getInArray($user) { return array('id' => $this->getId(), 'advertismentID' => $this->getAdvertismentID(), 'advertismentTitle' => $this->getAdvertisment()->getTitle(), 'advertismentUserID' => $this->getAdvertisment()->getUserID(), 'myself' => $this->getUser1()->getId() === $user->getId() ? $this->getUser1()->getInArray() : $this->getUser2()->getInArray(), 'user1' => $this->getUser1()->getInArray(), 'user2' => $this->getUser2()->getInArray(), 'messages' => Functions::arrayToJson($this->getMessages()), 'date' => $this->getLastUpdated()->format('d-m-Y'), 'time' => $this->getLastUpdated()->format('H:i:s')); }
public function getInArray() { return array('id' => $this->getId(), 'name' => $this->getName(), 'slug' => $this->slug, 'categories' => Functions::arrayToJsonWithoutParent($this->getCategories())); }
/** * @Security("has_role('ROLE_WEB_DEVELOPER')") * @return JsonResponse */ public function getErrorsAction() { $errors = $this->getDoctrine()->getRepository('NaidusvoeBundle:ErrorLog')->findBy(array(), array('date' => 'DESC'), 100, 0); return new JsonResponse(Functions::arrayToJson($errors)); }
/** * @Route("/api/get-main-advs", name="get-main-advs", options={"expose" = true}) * @return JsonResponse */ public function getAdvsOnMain() { $advs = $this->get('naidusvoe.advertisement')->getMainAdvs(); $advs['trade'] = Functions::arrayToJson($advs['trade']); $advs['find'] = Functions::arrayToJson($advs['find']); $advs['gift'] = Functions::arrayToJson($advs['gift']); return new JsonResponse($advs); }