當前位置: 首頁>>代碼示例>>PHP>>正文


PHP UserContext::toArray方法代碼示例

本文整理匯總了PHP中Pim\Bundle\UserBundle\Context\UserContext::toArray方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserContext::toArray方法的具體用法?PHP UserContext::toArray怎麽用?PHP UserContext::toArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Pim\Bundle\UserBundle\Context\UserContext的用法示例。


在下文中一共展示了UserContext::toArray方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: postAction

 /**
  * @param Request $request
  * @param string  $id
  *
  * @throws NotFoundHttpException     If product is not found or the user cannot see it
  * @throws AccessDeniedHttpException If the user does not have right to edit the product
  *
  * @return JsonResponse
  */
 public function postAction(Request $request, $id)
 {
     $product = $this->findProductOr404($id);
     if ($this->objectFilter->filterObject($product, 'pim.internal_api.product.edit')) {
         throw new AccessDeniedHttpException();
     }
     $data = json_decode($request->getContent(), true);
     try {
         $data = $this->productEditDataFilter->filterCollection($data, null, ['product' => $product]);
     } catch (ObjectNotFoundException $e) {
         throw new BadRequestHttpException();
     }
     // TODO: PEF should never update groups, no way to do so from the screen, if a product is added to
     // another group during the save, this relation will be removed, other issue is that variant groups are never
     // passed here, so a product is always removed from it's variant group when saved
     unset($data['groups']);
     $data = $this->convertLocalizedAttributes($data);
     $this->updateProduct($product, $data);
     $violations = $this->validator->validate($product);
     $violations->addAll($this->localizedConverter->getViolations());
     if (0 === $violations->count()) {
         $this->productSaver->save($product);
         $normalizationContext = $this->userContext->toArray() + ['filter_type' => 'pim.internal_api.product_value.view', 'disable_grouping_separator' => true];
         return new JsonResponse($this->normalizer->normalize($product, 'internal_api', $normalizationContext));
     } else {
         $errors = ['values' => $this->normalizer->normalize($violations, 'internal_api', ['product' => $product])];
         return new JsonResponse($errors, 400);
     }
 }
開發者ID:SamirBoulil,項目名稱:pim-community-dev,代碼行數:38,代碼來源:ProductController.php

示例2: postAction

 /**
  * @param Request $request
  * @param string  $code
  *
  * @throws NotFoundHttpException     If product is not found or the user cannot see it
  * @throws AccessDeniedHttpException If the user does not have permissions to edit the product
  *
  * @return JsonResponse
  */
 public function postAction(Request $request, $code)
 {
     $group = $this->groupRepository->findOneByIdentifier($code);
     if (null === $group) {
         throw new NotFoundHttpException(sprintf('Group with code "%s" not found', $code));
     }
     $data = json_decode($request->getContent(), true);
     $this->updater->update($group, $data);
     $violations = $this->validator->validate($group);
     if (0 < $violations->count()) {
         $errors = $this->violationNormalizer->normalize($violations, 'internal_api', $this->userContext->toArray());
         return new JsonResponse($errors, 400);
     }
     $this->saver->save($group);
     return new JsonResponse($this->normalizer->normalize($group, 'internal_api', $this->userContext->toArray()));
 }
開發者ID:a2xchip,項目名稱:pim-community-dev,代碼行數:25,代碼來源:GroupController.php

示例3: postAction

 /**
  * @param Request $request
  * @param string  $code
  *
  * @throws NotFoundHttpException     If product is not found or the user cannot see it
  * @throws AccessDeniedHttpException If the user does not have right to edit the product
  *
  * @return JsonResponse
  */
 public function postAction(Request $request, $code)
 {
     $variantGroup = $this->repository->findOneByIdentifier($code);
     if (null === $variantGroup) {
         throw new NotFoundHttpException(sprintf('Variant group with code "%s" not found', $code));
     }
     $data = json_decode($request->getContent(), true);
     $data = $this->convertLocalizedAttributes($data);
     $data = $this->variantGroupDataFilter->filterCollection($data, null);
     $this->updater->update($variantGroup, $data);
     $violations = $this->validator->validate($variantGroup);
     $violations->addAll($this->validator->validate($variantGroup->getProductTemplate()));
     $violations->addAll($this->attributeConverter->getViolations());
     if (0 < $violations->count()) {
         $errors = $this->violationNormalizer->normalize($violations, 'internal_api', $this->userContext->toArray() + ['product' => $variantGroup->getProductTemplate()]);
         return new JsonResponse($errors, 400);
     }
     $this->saver->save($variantGroup, ['copy_values_to_products' => true]);
     return new JsonResponse($this->normalizer->normalize($variantGroup, 'internal_api', $this->userContext->toArray() + ['with_variant_group_values' => true]));
 }
開發者ID:a2xchip,項目名稱:pim-community-dev,代碼行數:29,代碼來源:VariantGroupController.php

示例4: postAction

 /**
  * @param Request $request
  * @param string  $id
  *
  * @throws NotFoundHttpException     If product is not found or the user cannot see it
  * @throws AccessDeniedHttpException If the user does not have right to edit the product
  *
  * @return JsonResponse
  */
 public function postAction(Request $request, $id)
 {
     $product = $this->findProductOr404($id);
     if ($this->objectFilter->filterObject($product, 'pim.internal_api.product.edit')) {
         throw new AccessDeniedHttpException();
     }
     $data = json_decode($request->getContent(), true);
     try {
         $data = $this->productEditDataFilter->filterCollection($data, null, ['product' => $product]);
     } catch (ObjectNotFoundException $e) {
         throw new BadRequestHttpException();
     }
     $this->updateProduct($product, $data);
     $violations = $this->validator->validate($product);
     $violations->addAll($this->localizedConverter->getViolations());
     if (0 === $violations->count()) {
         $this->productSaver->save($product);
         $normalizationContext = $this->userContext->toArray() + ['filter_types' => ['pim.internal_api.product_value.view'], 'disable_grouping_separator' => true];
         return new JsonResponse($this->normalizer->normalize($product, 'internal_api', $normalizationContext));
     }
     $errors = ['values' => $this->normalizer->normalize($violations, 'internal_api', ['product' => $product])];
     return new JsonResponse($errors, 400);
 }
開發者ID:a2xchip,項目名稱:pim-community-dev,代碼行數:32,代碼來源:ProductController.php


注:本文中的Pim\Bundle\UserBundle\Context\UserContext::toArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。