Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
TypesList.php
Go to the documentation of this file.
1 <?php
8 
10 {
14  private $inputTypeFactory;
15 
19  private $attributeTypeFactory;
20 
24  private $dataObjectHelper;
25 
31  public function __construct(
32  \Magento\Catalog\Model\Product\Attribute\Source\InputtypeFactory $inputTypeFactory,
33  \Magento\Catalog\Api\Data\ProductAttributeTypeInterfaceFactory $attributeTypeFactory,
34  \Magento\Framework\Api\DataObjectHelper $dataObjectHelper
35  ) {
36  $this->inputTypeFactory = $inputTypeFactory;
37  $this->attributeTypeFactory = $attributeTypeFactory;
38  $this->dataObjectHelper = $dataObjectHelper;
39  }
40 
44  public function getItems()
45  {
46  $types = [];
47  $inputType = $this->inputTypeFactory->create();
48 
49  foreach ($inputType->toOptionArray() as $option) {
50  $type = $this->attributeTypeFactory->create();
51  $this->dataObjectHelper->populateWithArray(
52  $type,
53  $option,
54  \Magento\Catalog\Api\Data\ProductAttributeTypeInterface::class
55  );
56  $types[] = $type;
57  }
58  return $types;
59  }
60 }
__construct(\Magento\Catalog\Model\Product\Attribute\Source\InputtypeFactory $inputTypeFactory, \Magento\Catalog\Api\Data\ProductAttributeTypeInterfaceFactory $attributeTypeFactory, \Magento\Framework\Api\DataObjectHelper $dataObjectHelper)
Definition: TypesList.php:31
$type
Definition: item.phtml:13