本文整理汇总了PHP中Pim\Bundle\CatalogBundle\Repository\AttributeRepositoryInterface::getAttributeTypeByCodes方法的典型用法代码示例。如果您正苦于以下问题:PHP AttributeRepositoryInterface::getAttributeTypeByCodes方法的具体用法?PHP AttributeRepositoryInterface::getAttributeTypeByCodes怎么用?PHP AttributeRepositoryInterface::getAttributeTypeByCodes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pim\Bundle\CatalogBundle\Repository\AttributeRepositoryInterface
的用法示例。
在下文中一共展示了AttributeRepositoryInterface::getAttributeTypeByCodes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: convert
/**
* {@inheritdoc}
*/
public function convert(array $items, array $options = [])
{
$attributeTypes = $this->attributeRepository->getAttributeTypeByCodes(array_keys($items));
foreach ($items as $code => $item) {
if (isset($attributeTypes[$code])) {
$localizer = $this->localizerRegistry->getLocalizer($attributeTypes[$code]);
if (null !== $localizer) {
foreach ($item as $i => $data) {
$items[$code][$i] = $this->convertAttribute($localizer, $data, $options, $code);
}
}
}
}
return $items;
}
示例2: convertLocalizedToDefaultValues
/**
* {@inheritdoc}
*/
public function convertLocalizedToDefaultValues(array $items, array $options = [])
{
$this->violations = new ConstraintViolationList();
$attributeTypes = $this->attributeRepository->getAttributeTypeByCodes(array_keys($items));
foreach ($items as $code => $item) {
if (isset($attributeTypes[$code])) {
$localizer = $this->localizerRegistry->getLocalizer($attributeTypes[$code]);
if (null !== $localizer) {
foreach ($item as $index => $data) {
$items[$code][$index] = $this->convertLocalizedToDefaultValue($localizer, $data, $options, $this->buildPropertyPath($data, $code));
}
}
}
}
return $items;
}
示例3: filter
/**
* {@inheritdoc}
*/
public function filter(ProductInterface $product, array $newValues)
{
$originalValues = $this->getOriginalProduct($product);
$attributeTypes = $this->attributeRepository->getAttributeTypeByCodes(array_keys($newValues));
$result = [];
foreach ($newValues as $code => $value) {
if (in_array($code, $this->productFields)) {
$data = $this->compareField($originalValues, $value, $code);
} elseif (isset($attributeTypes[$code])) {
$data = $this->compareAttribute($originalValues, $value, $attributeTypes, $code);
} else {
throw new \LogicException(sprintf('Cannot filter value of field "%s"', $code));
}
if (null !== $data) {
$result = $this->mergeValueToResult($result, $data);
}
}
return $result;
}