/**
  * Get a list of available attribute types
  *
  * @return string[]
  */
 public function getAttributeTypes()
 {
     $types = $this->registry->getAliases();
     $choices = [];
     foreach ($types as $type) {
         $choices[$type] = $type;
     }
     asort($choices);
     return $choices;
 }
 /**
  * Create and configure an attribute
  *
  * @param string|null $type
  *
  * @return AttributeInterface
  */
 public function createAttribute($type = null)
 {
     $attribute = new $this->attributeClass();
     $attribute->setEntityType($this->productClass);
     if ($type) {
         $attributeType = $this->registry->get($type);
         $attribute->setBackendType($attributeType->getBackendType());
         $attribute->setAttributeType($attributeType->getName());
     }
     return $attribute;
 }
 /**
  * @param ProductValueInterface $value
  * @param array                 $context
  *
  * @return FormInterface
  */
 public function createProductValueForm(ProductValueInterface $value, array $context)
 {
     $attributeTypeAlias = $value->getAttribute()->getAttributeType();
     $attributeType = $this->attTypeRegistry->get($attributeTypeAlias);
     $name = $attributeType->prepareValueFormName($value);
     $type = $attributeType->prepareValueFormAlias($value);
     $data = $attributeType->prepareValueFormData($value);
     $options = array_merge($attributeType->prepareValueFormConstraints($value), $attributeType->prepareValueFormOptions($value));
     $event = new CreateProductValueFormEvent($value, $type, $data, $options, $context);
     $this->eventDispatcher->dispatch(ProductEvents::CREATE_VALUE_FORM, $event);
     $valueForm = $this->formFactory->createNamed($name, $event->getFormType(), $event->getFormData(), $event->getFormOptions());
     return $valueForm;
 }
 /**
  * Create and configure an attribute
  *
  * @param string|null $type
  *
  * @return AttributeInterface
  */
 public function createAttribute($type = null)
 {
     $attribute = new $this->attributeClass();
     $attribute->setEntityType($this->productClass);
     if (null !== $type && '' !== $type) {
         $attributeType = $this->registry->get($type);
         $attribute->setBackendType($attributeType->getBackendType());
         $attribute->setAttributeType($attributeType->getName());
         if ($attributeType instanceof IdentifierType) {
             $attribute->setUnique(true);
         }
     }
     return $attribute;
 }