当前位置: 首页>>代码示例>>PHP>>正文


PHP UserContext::getUiLocale方法代码示例

本文整理汇总了PHP中Pim\Bundle\UserBundle\Context\UserContext::getUiLocale方法的典型用法代码示例。如果您正苦于以下问题:PHP UserContext::getUiLocale方法的具体用法?PHP UserContext::getUiLocale怎么用?PHP UserContext::getUiLocale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pim\Bundle\UserBundle\Context\UserContext的用法示例。


在下文中一共展示了UserContext::getUiLocale方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: updateProduct

 /**
  * Updates product with the provided request data
  *
  * @param ProductInterface $product
  * @param array            $data
  */
 protected function updateProduct(ProductInterface $product, array $data)
 {
     $values = $this->localizedConverter->convertToDefaultFormats($data['values'], ['locale' => $this->userContext->getUiLocale()->getCode()]);
     $values = $this->emptyValuesFilter->filter($product, $values);
     unset($data['values']);
     $data = array_replace($data, $values);
     $this->productUpdater->update($product, $data);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:14,代码来源:ProductController.php

示例2: getActions

 /**
  * {@inheritdoc}
  */
 public function getActions()
 {
     $actions = [];
     $options = ['entity' => 'product', 'locale' => $this->userContext->getUiLocale(), 'disable_grouping_separator' => true];
     foreach ($this->values as $value) {
         $rawData = $this->normalizer->normalize($value->getData(), 'json', $options);
         // if the value is localizable, let's use the locale the user has chosen in the form
         $locale = null !== $value->getLocale() ? $this->getLocale()->getCode() : null;
         $actions[] = ['field' => $value->getAttribute()->getCode(), 'value' => $rawData, 'options' => ['locale' => $locale, 'scope' => $value->getScope()]];
     }
     return $actions;
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:15,代码来源:EditCommonAttributes.php

示例3: hasValidValues

 /**
  * Apply current values to a fake product and test its integrity with the product validator.
  * If violations are raised, values are not valid.
  *
  * Errors are stored in json format to be useable by the Product Edit Form.
  *
  * @return bool
  */
 public function hasValidValues()
 {
     $data = json_decode($this->values, true);
     $locale = $this->userContext->getUiLocale()->getCode();
     $data = $this->localizedConverter->convertToDefaultFormats($data, ['locale' => $locale]);
     $product = $this->productBuilder->createProduct('FAKE_SKU_FOR_MASS_EDIT_VALIDATION_' . microtime());
     $this->productUpdater->update($product, $data);
     $violations = $this->productValidator->validate($product);
     $violations->addAll($this->localizedConverter->getViolations());
     $errors = ['values' => $this->internalNormalizer->normalize($violations, 'internal_api', ['product' => $product])];
     $this->errors = json_encode($errors);
     return 0 === $violations->count();
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:21,代码来源:EditCommonAttributes.php

示例4: buildContext

 /**
  * Build context for normalizer
  *
  * @return array
  */
 protected function buildContext()
 {
     $channels = array_keys($this->userContext->getChannelChoicesWithUserChannel());
     $locales = $this->userContext->getUserLocaleCodes();
     return ['locales' => $locales, 'channels' => $channels, 'filter_type' => 'pim.internal_api.product_value.view', 'locale' => $this->userContext->getUiLocale()->getCode(), 'disable_grouping_separator' => true];
 }
开发者ID:VinceBLOT,项目名称:pim-community-dev,代码行数:11,代码来源:ProductController.php

示例5: convertLocalizedAttributes

 /**
  * Convert localized attributes to the default format
  *
  * @param array $data
  *
  * @return array
  */
 protected function convertLocalizedAttributes(array $data)
 {
     $locale = $this->userContext->getUiLocale()->getCode();
     $data['values'] = $this->attributeConverter->convertToDefaultFormats($data['values'], ['locale' => $locale]);
     return $data;
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:13,代码来源:VariantGroupController.php


注:本文中的Pim\Bundle\UserBundle\Context\UserContext::getUiLocale方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。