Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AddressAttributeData.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
15 
20 {
24  private $addressMetadata;
25 
29  private $escaper;
30 
35  public function __construct(
36  AddressMetadataInterface $addressMetadata,
37  Escaper $escaper
38  ) {
39 
40  $this->addressMetadata = $addressMetadata;
41  $this->escaper = $escaper;
42  }
43 
51  public function getFrontendLabel(string $attributeCode): string
52  {
53  try {
54  $attribute = $this->addressMetadata->getAttributeMetadata($attributeCode);
55  $frontendLabel = $attribute->getFrontendLabel();
56  } catch (NoSuchEntityException $e) {
57  $frontendLabel = '';
58  }
59 
60  return $this->escaper->escapeHtml(__($frontendLabel));
61  }
62 }
__()
Definition: __.php:13
$attributeCode
Definition: extend.phtml:12
__construct(AddressMetadataInterface $addressMetadata, Escaper $escaper)