Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AttributeMetadataDataProvider.php
Go to the documentation of this file.
1 <?php
7 namespace Magento\Customer\Model;
8 
10 
15 {
19  private $eavConfig;
20 
24  private $attrFormCollectionFactory;
25 
29  private $storeManager;
30 
38  public function __construct(
39  \Magento\Eav\Model\Config $eavConfig,
40  \Magento\Customer\Model\ResourceModel\Form\Attribute\CollectionFactory $attrFormCollectionFactory,
41  \Magento\Store\Model\StoreManager $storeManager
42  ) {
43  $this->eavConfig = $eavConfig;
44  $this->attrFormCollectionFactory = $attrFormCollectionFactory;
45  $this->storeManager = $storeManager;
46  }
47 
56  {
57  return $this->eavConfig->getAttribute($entityType, $attributeCode);
58  }
59 
69  {
70  if (null === $storeId) {
71  $storeId = $this->storeManager->getStore()->getId();
72  }
73  $object = new \Magento\Framework\DataObject(
74  [
75  'store_id' => $storeId,
76  'attribute_set_id' => $attributeSetId,
77  ]
78  );
79  return $this->eavConfig->getEntityAttributeCodes($entityType, $object);
80  }
81 
89  public function loadAttributesCollection($entityType, $formCode)
90  {
91  $attributesFormCollection = $this->attrFormCollectionFactory->create();
92  $attributesFormCollection->setStore($this->storeManager->getStore())
93  ->setEntityType($entityType)
94  ->addFormCodeFilter($formCode)
95  ->setSortOrder();
96 
97  return $attributesFormCollection;
98  }
99 }
getAllAttributeCodes($entityType, $attributeSetId=0, $storeId=null)
$storeManager
__construct(\Magento\Eav\Model\Config $eavConfig, \Magento\Customer\Model\ResourceModel\Form\Attribute\CollectionFactory $attrFormCollectionFactory, \Magento\Store\Model\StoreManager $storeManager)
$attributeCode
Definition: extend.phtml:12