public function loadTagging(BaseTaggable $resource)
 {
     if ($resource instanceof LazyLoadingTaggableInterface) {
         $resource->setTagLoader(function (Taggable $taggable) {
             parent::loadTagging($taggable);
         });
         return;
     }
     parent::loadTagging($resource);
 }
Beispiel #2
0
 /**
  * Информация о площадке по id
  *
  * @param Platform $platform
  *
  * @Rest\Get("platforms/{id}", requirements={"id"="\d+"})
  * @ParamConverter("platform", class="VifeedPlatformBundle:Platform")
  * @ApiDoc(
  *     section="Platform API",
  *     requirements={
  *       {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="id площадки"}
  *     },
  *     output={
  *          "class"="Vifeed\PlatformBundle\Entity\Platform",
  *          "groups"={"own"}
  *     },
  *     statusCodes={
  *         200="Returned when successful",
  *         403="Returned when the user is not authorized to use this method",
  *         404="Returned when platform not found"
  *     }
  * )
  *
  * @return Response
  */
 public function getPlatformAction(Platform $platform)
 {
     if ($this->getUser() !== $platform->getUser()) {
         throw new AccessDeniedHttpException('Вы не можете просматривать площадки');
     }
     $this->tagManager->loadTagging($platform);
     $context = new SerializationContext();
     $context->setGroups(['own']);
     $view = new View($platform);
     $view->setSerializationContext($context);
     return $this->handleView($view);
 }
Beispiel #3
0
 /**
  * Информация о кампании по id
  *
  * @param Campaign $campaign
  *
  * @Rest\Get("campaigns/{id}", requirements={"id"="\d+"})
  * @ParamConverter("campaign", class="VifeedCampaignBundle:Campaign")
  * @ApiDoc(
  *     section="Campaign API",
  *     requirements={
  *       {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="id кампании"}
  *     },
  *     output={
  *          "class"="Vifeed\CampaignBundle\Entity\Campaign",
  *          "groups"={"own", "default"}
  *     },
  *     statusCodes={
  *         200="Returned when successful",
  *         403="Returned when the user is not authorized to use this method",
  *         404="Returned when campaign not found"
  *     }
  * )
  *
  * @return Response
  */
 public function getCampaignAction(Campaign $campaign)
 {
     $this->tagManager->loadTagging($campaign);
     $context = new SerializationContext();
     $userType = $this->getUser()->getType();
     if ($userType == User::TYPE_ADVERTISER) {
         if ($campaign->getUser() == $this->getUser()) {
             $context->setGroups(['own']);
         } else {
             throw new AccessDeniedHttpException();
         }
     } elseif ($userType == User::TYPE_PUBLISHER) {
         $context->setGroups(['default']);
     }
     $view = new View($campaign);
     $view->setSerializationContext($context);
     return $this->handleView($view);
 }