本文整理汇总了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);
}
示例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;
}
示例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();
}
示例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];
}
示例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;
}