function it_provides_available_axis_as_a_sorted_choice($registry, AttributeRepositoryInterface $attRepository, AttributeInterface $attribute1, AttributeInterface $attribute2) { $attribute1->getId()->willReturn(1); $attribute1->getLabel()->willReturn('Foo'); $attribute2->getId()->willReturn(2); $attribute2->getLabel()->willReturn('Bar'); $registry->getRepository(self::ATTRIBUTE_CLASS)->willReturn($attRepository); $attRepository->findAllAxis()->willReturn([$attribute1, $attribute2]); $this->getAvailableAxisChoices()->shouldReturn([2 => 'Bar', 1 => 'Foo']); }
/** * Prepare attribute view * * @param AttributeInterface $attribute * @param ProductValueInterface $value * @param FormView $view * * @return array */ protected function prepareAttributeView(AttributeInterface $attribute, ProductValueInterface $value, FormView $view) { $attributeView = ['id' => $attribute->getId(), 'isRemovable' => $value->isRemovable(), 'code' => $attribute->getCode(), 'label' => $attribute->getLabel(), 'sortOrder' => $attribute->getSortOrder(), 'allowValueCreation' => in_array($attribute->getAttributeType(), $this->choiceAttributeTypes), 'locale' => $value->getLocale()]; if ($attribute->isScopable()) { $attributeView['values'] = array_merge($this->getAttributeValues($attribute, $value->getLocale()), [$value->getScope() => $view]); ksort($attributeView['values']); } else { $attributeView['value'] = $view; } $classes = $this->getAttributeClasses($attribute); if (!empty($classes)) { $attributeView['classes'] = $classes; } return $attributeView; }