/** * @param Deal $object * @return array */ public function reverseConvert($object) { $deal = $this->em->getReference('CoreBundle:Deal', $object->getId()); $dealState = $deal->getState(); if ($dealState instanceof DealStateInterface) { return ['id' => $dealState->getId(), 'name' => $dealState->getName(), 'icon' => $dealState->getIcon()]; } return null; }
/** * @return Deal */ public function create() { $deal = new Deal(); $deal->setAccount($this->getCurrentAccount()); if (!$this->securityContext->getToken() instanceof AnonymousToken) { $deal->setUser($this->securityContext->getToken()->getUser()); } return $deal; }
/** * @ApiDoc( * section="Deal", * description="Get specified deal product", * filters={ * {"name"="token", "type"="text"} * } * ) * @Method("GET") * @Route("/deals/{id}/product") * @ParamConverter("deal", converter="account.doctrine.orm") * @param Deal $deal * @return JsonResponse|Response */ public function getProductAction(Deal $deal) { return new JsonResponse($this->get('perfico_crm.api.transformer')->transform($deal->getProduct(), new ProductMap(), 'products')); }