Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AttributeResolver.php
Go to the documentation of this file.
1 <?php
7 
12 
14 {
19 
23  public function __construct(
25  ) {
26  $this->attributeMetadataDataProvider = $attributeMetadataDataProvider;
27  }
28 
37  public function getModelByAttribute($entityType, AttributeMetadataInterface $attribute)
38  {
40  $model = $this->attributeMetadataDataProvider->getAttribute(
42  $attribute->getAttributeCode()
43  );
44  if ($model) {
45  return $model;
46  } else {
47  throw new NoSuchEntityException(
48  __(
49  'No such entity with %fieldName = %fieldValue, %field2Name = %field2Value',
50  [
51  'fieldName' => 'entityType',
52  'fieldValue' => $entityType,
53  'field2Name' => 'attributeCode',
54  'field2Value' => $attribute->getAttributeCode()
55  ]
56  )
57  );
58  }
59  }
60 }
__construct(AttributeMetadataDataProvider $attributeMetadataDataProvider)
__()
Definition: __.php:13