8 use Magento\Customer\Api\Data\OptionInterfaceFactory;
9 use Magento\Customer\Api\Data\ValidationRuleInterfaceFactory;
10 use Magento\Customer\Api\Data\AttributeMetadataInterfaceFactory;
21 private $optionFactory;
26 private $validationRuleFactory;
31 private $attributeMetadataFactory;
47 OptionInterfaceFactory $optionFactory,
48 ValidationRuleInterfaceFactory $validationRuleFactory,
49 AttributeMetadataInterfaceFactory $attributeMetadataFactory,
52 $this->optionFactory = $optionFactory;
53 $this->validationRuleFactory = $validationRuleFactory;
54 $this->attributeMetadataFactory = $attributeMetadataFactory;
69 $optionDataObject = $this->optionFactory->create();
70 if (!is_array(
$option[
'value'])) {
71 $optionDataObject->setValue(
$option[
'value']);
74 foreach (
$option[
'value'] as $optionArrayValues) {
75 $optionObject = $this->optionFactory->create();
76 $this->dataObjectHelper->populateWithArray(
81 $optionArray[] = $optionObject;
83 $optionDataObject->setOptions($optionArray);
85 $optionDataObject->setLabel(
$option[
'label']);
89 $validationRules = [];
91 $validationRule = $this->validationRuleFactory->create()
94 $validationRules[] = $validationRule;
97 $attributeMetaData = $this->attributeMetadataFactory->create();
100 $attributeMetaData->setDefaultValue(
$attribute->getDefaultValue());
103 return $attributeMetaData->setAttributeCode(
$attribute->getAttributeCode())
104 ->setFrontendInput(
$attribute->getFrontendInput())
105 ->setInputFilter((
string)
$attribute->getInputFilter())
107 ->setValidationRules($validationRules)
108 ->setIsVisible((
boolean)
$attribute->getIsVisible())
109 ->setIsRequired((
boolean)
$attribute->getIsRequired())
110 ->setMultilineCount((
int)
$attribute->getMultilineCount())
111 ->setDataModel((
string)
$attribute->getDataModel())
113 ->setFrontendClass(
$attribute->getFrontend()->getClass())
114 ->setFrontendLabel(
$attribute->getFrontendLabel())
116 ->setIsSystem((
boolean)
$attribute->getIsSystem())
117 ->setIsUserDefined((
boolean)
$attribute->getIsUserDefined())
118 ->setBackendType(
$attribute->getBackendType())
119 ->setSortOrder((
int)
$attribute->getSortOrder())
120 ->setIsUsedInGrid(
$attribute->getIsUsedInGrid())
121 ->setIsVisibleInGrid(
$attribute->getIsVisibleInGrid())
122 ->setIsFilterableInGrid(
$attribute->getIsFilterableInGrid())
123 ->setIsSearchableInGrid(
$attribute->getIsSearchableInGrid());
if(!isset($_GET['name'])) $name