本文整理汇总了PHP中Pim\Bundle\CatalogBundle\Model\AttributeInterface::isLocaleSpecific方法的典型用法代码示例。如果您正苦于以下问题:PHP AttributeInterface::isLocaleSpecific方法的具体用法?PHP AttributeInterface::isLocaleSpecific怎么用?PHP AttributeInterface::isLocaleSpecific使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pim\Bundle\CatalogBundle\Model\AttributeInterface
的用法示例。
在下文中一共展示了AttributeInterface::isLocaleSpecific方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
function it_resolves_eligible_values_for_a_set_of_attributes($localeRepository, $channelRepository, AttributeInterface $sku, AttributeInterface $name, AttributeInterface $desc, AttributeInterface $tax, LocaleInterface $fr, LocaleInterface $en, ChannelInterface $ecom, ChannelInterface $print)
{
$sku->getCode()->willReturn('sku');
$sku->getAttributeType()->willReturn('pim_catalog_identifier');
$sku->isLocalizable()->willReturn(false);
$sku->isScopable()->willReturn(false);
$sku->isLocaleSpecific()->willReturn(false);
$name->getCode()->willReturn('name');
$name->getAttributeType()->willReturn('pim_catalog_text');
$name->isLocalizable()->willReturn(true);
$name->isScopable()->willReturn(false);
$name->isLocaleSpecific()->willReturn(false);
$desc->getCode()->willReturn('description');
$desc->getAttributeType()->willReturn('pim_catalog_text');
$desc->isLocalizable()->willReturn(true);
$desc->isScopable()->willReturn(true);
$desc->isLocaleSpecific()->willReturn(false);
$tax->getCode()->willReturn('tax');
$tax->getAttributeType()->willReturn('pim_catalog_text');
$tax->isLocalizable()->willReturn(true);
$tax->isScopable()->willReturn(false);
$tax->isLocaleSpecific()->willReturn(true);
$tax->getLocaleSpecificCodes()->willReturn(['fr_FR']);
$fr->getCode()->willReturn('fr_FR');
$en->getCode()->willReturn('en_US');
$localeRepository->getActivatedLocales()->willReturn([$fr, $en]);
$ecom->getCode()->willReturn('ecommerce');
$ecom->getLocales()->willReturn([$en, $fr]);
$print->getCode()->willReturn('print');
$print->getLocales()->willReturn([$en, $fr]);
$channelRepository->findAll()->willReturn([$ecom, $print]);
$this->resolveEligibleValues([$sku, $name, $desc, $tax])->shouldReturn([['attribute' => 'sku', 'type' => 'pim_catalog_identifier', 'locale' => null, 'scope' => null], ['attribute' => 'name', 'type' => 'pim_catalog_text', 'locale' => 'fr_FR', 'scope' => null], ['attribute' => 'name', 'type' => 'pim_catalog_text', 'locale' => 'en_US', 'scope' => null], ['attribute' => 'description', 'type' => 'pim_catalog_text', 'locale' => 'en_US', 'scope' => 'ecommerce'], ['attribute' => 'description', 'type' => 'pim_catalog_text', 'locale' => 'fr_FR', 'scope' => 'ecommerce'], ['attribute' => 'description', 'type' => 'pim_catalog_text', 'locale' => 'en_US', 'scope' => 'print'], ['attribute' => 'description', 'type' => 'pim_catalog_text', 'locale' => 'fr_FR', 'scope' => 'print'], ['attribute' => 'tax', 'type' => 'pim_catalog_text', 'locale' => 'fr_FR', 'scope' => null]]);
}
示例2: filterExpectedValues
/**
* Filter expected values based on the locales available for the provided attribute
*
* @param AttributeInterface $attribute
* @param array $values
*
* @return array
*/
protected function filterExpectedValues(AttributeInterface $attribute, array $values)
{
if ($attribute->isLocaleSpecific()) {
$availableLocales = $attribute->getLocaleSpecificCodes();
foreach ($values as $index => $value) {
if ($value['locale'] && !in_array($value['locale'], $availableLocales)) {
unset($values[$index]);
}
}
}
return $values;
}
示例3:
function it_adds_missing_product_values_from_family_on_new_product(FamilyInterface $family, ProductInterface $product, AttributeInterface $sku, AttributeInterface $name, AttributeInterface $desc, $localeRepository, LocaleInterface $fr, LocaleInterface $en, $channelRepository, ChannelInterface $ecom, ChannelInterface $print, ProductValueInterface $skuValue)
{
// get expected attributes
$product->getAttributes()->willReturn([$sku]);
$product->getFamily()->willReturn($family);
$family->getAttributes()->willReturn([$sku, $name, $desc]);
// get expected values
$sku->getCode()->willReturn('sku');
$sku->getAttributeType()->willReturn('pim_catalog_identifier');
$sku->isLocalizable()->willReturn(false);
$sku->isScopable()->willReturn(false);
$sku->isLocaleSpecific()->willReturn(false);
$name->getCode()->willReturn('name');
$name->getAttributeType()->willReturn('pim_catalog_text');
$name->isLocalizable()->willReturn(true);
$name->isScopable()->willReturn(false);
$name->isLocaleSpecific()->willReturn(false);
$desc->getCode()->willReturn('desc');
$desc->getAttributeType()->willReturn('pim_catalog_text');
$desc->isLocalizable()->willReturn(true);
$desc->isScopable()->willReturn(true);
$desc->isLocaleSpecific()->willReturn(false);
$fr->getCode()->willReturn('fr_FR');
$en->getCode()->willReturn('fr_FR');
$localeRepository->getActivatedLocales()->willReturn([$fr, $en]);
$ecom->getCode()->willReturn('ecom');
$ecom->getLocales()->willReturn([$en, $fr]);
$print->getCode()->willReturn('print');
$print->getLocales()->willReturn([$en, $fr]);
$channelRepository->findAll()->willReturn([$ecom, $print]);
// get existing values
$skuValue->getAttribute()->willReturn($sku);
$skuValue->getLocale()->willReturn(null);
$skuValue->getScope()->willReturn(null);
$product->getValues()->willReturn([$skuValue]);
// add 6 new values : 4 desc (locales x scopes) + 2 name (locales
$product->addValue(Argument::any())->shouldBeCalledTimes(6);
$this->addMissingProductValues($product);
}
示例4: getNewValuesData
/**
* @param AttributeInterface $attribute
* @param array $values
*
* @throws ObjectNotFoundException
*
* @return array
*/
protected function getNewValuesData(AttributeInterface $attribute, array $values)
{
$newValues = [];
foreach ($values as $value) {
$acceptValue = true;
if (null !== $value['locale']) {
$isAuthorizedOnLocale = !$this->objectFilter->filterObject($this->getLocale($value['locale']), 'pim.internal_api.locale.edit');
$isEditableOnLocale = $attribute->isLocaleSpecific() ? in_array($value['locale'], $attribute->getLocaleSpecificCodes()) : true;
$acceptValue = $isAuthorizedOnLocale && $isEditableOnLocale;
}
if ($acceptValue) {
$newValues[] = $value;
}
}
return $newValues;
}
示例5:
function it_throws_exception_when_the_field_name_is_not_consistent_with_the_channel_locale($managerRegistry, IdentifiableObjectRepositoryInterface $repository, AttributeInterface $attribute, IdentifiableObjectRepositoryInterface $channelRepository, IdentifiableObjectRepositoryInterface $localeRepository, LocaleInterface $locale, ChannelInterface $channel)
{
// localizable without the associated locale not in the channel
$attribute->getCode()->willReturn('description');
$attribute->isLocalizable()->willReturn(true);
$attribute->isScopable()->willReturn(true);
$attribute->getBackendType()->willReturn('text');
$attribute->isLocaleSpecific()->willReturn(false);
$attributeInfos = ['attribute' => $attribute, 'locale_code' => 'de_DE', 'scope_code' => 'mobile'];
$managerRegistry->getRepository(self::ATTRIBUTE_CLASS)->willReturn($repository);
$repository->findOneByIdentifier('description')->willReturn($attribute);
$managerRegistry->getRepository(self::CHANNEL_CLASS)->shouldBeCalled()->willReturn($channelRepository);
$channelRepository->findOneByIdentifier($attributeInfos['scope_code'])->shouldBeCalled()->willReturn($channel);
$managerRegistry->getRepository(self::LOCALE_CLASS)->shouldBeCalled()->willReturn($localeRepository);
$localeRepository->findOneByIdentifier($attributeInfos['locale_code'])->shouldBeCalled()->willReturn($locale);
$channel->hasLocale($locale)->shouldBeCalled()->willReturn(false);
$this->shouldThrow(new \InvalidArgumentException('The locale "de_DE" of the field "description-de_DE-mobile" is not available in scope "mobile"'))->duringExtractAttributeFieldNameInfos('description-de_DE-mobile');
}
示例6: checkForLocaleSpecificValue
/**
* Check if provided locales for an locale specific attribute exist
*
* @param AttributeInterface $attribute
* @param array $explodedFieldNames
*/
protected function checkForLocaleSpecificValue(AttributeInterface $attribute, array $explodedFieldNames)
{
if ($attribute->isLocaleSpecific()) {
$attributeInfo = $this->extractAttributeInfos($attribute, $explodedFieldNames);
$availableLocales = $attribute->getLocaleSpecificCodes();
if (!in_array($explodedFieldNames[1], $availableLocales)) {
throw new \LogicException(sprintf('The provided specific locale "%s" does not exist for "%s" attribute ', $attributeInfo['locale_code'], $attribute->getCode()));
}
}
}