Skip to content

Commit 574f052

Browse files
committed
Extract some values and helpers
Extract them to shorten lines and resolve codestyle warnings
1 parent 51f4964 commit 574f052

File tree

1 file changed

+24
-17
lines changed
  • app/code/Magento/Customer/view/frontend/templates/address

1 file changed

+24
-17
lines changed

app/code/Magento/Customer/view/frontend/templates/address/edit.phtml

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
<?php $_company = $block->getLayout()->createBlock(\Magento\Customer\Block\Widget\Company::class) ?>
1010
<?php $_telephone = $block->getLayout()->createBlock(\Magento\Customer\Block\Widget\Telephone::class) ?>
1111
<?php $_fax = $block->getLayout()->createBlock(\Magento\Customer\Block\Widget\Fax::class) ?>
12+
<?php $_country_id = $block->getAttributeData()->getFrontendLabel('country_id'); ?>
13+
<?php $_street = $block->getAttributeData()->getFrontendLabel('street'); ?>
14+
<?php $_city = $block->getAttributeData()->getFrontendLabel('city'); ?>
15+
<?php $_region = $block->getAttributeData()->getFrontendLabel('region'); ?>
16+
<?php $_data_helper = $this->helper(\Magento\Directory\Helper\Data::class); ?>
17+
<?php $_address_helper = $this->helper(\Magento\Customer\Helper\Address::class); ?>
1218
<form class="form-address-edit"
1319
action="<?= $block->escapeUrl($block->getSaveUrl()) ?>"
1420
method="post"
@@ -37,19 +43,19 @@
3743
</fieldset>
3844
<fieldset class="fieldset">
3945
<legend class="legend"><span><?= $block->escapeHtml(__('Address')) ?></span></legend><br>
40-
<?php $_streetValidationClass = $this->helper(\Magento\Customer\Helper\Address::class)->getAttributeValidationClass('street'); ?>
46+
<?php $_streetValidationClass = $_address_helper->getAttributeValidationClass('street'); ?>
4147
<div class="field street required">
42-
<label for="street_1" class="label"><span><?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('street') ?></span></label>
48+
<label for="street_1" class="label"><span><?= /* @noEscape */ $_street ?></span></label>
4349
<div class="control">
4450
<input type="text"
4551
name="street[]"
4652
value="<?= $block->escapeHtmlAttr($block->getStreetLine(1)) ?>"
47-
title="<?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('street') ?>"
53+
title="<?= /* @noEscape */ $_street ?>"
4854
id="street_1"
4955
class="input-text <?= $block->escapeHtmlAttr($_streetValidationClass) ?>"/>
5056
<div class="nested">
5157
<?php $_streetValidationClass = trim(str_replace('required-entry', '', $_streetValidationClass)); ?>
52-
<?php for ($_i = 1, $_n = $this->helper(\Magento\Customer\Helper\Address::class)->getStreetLines(); $_i < $_n; $_i++): ?>
58+
<?php for ($_i = 1, $_n = $_address_helper->getStreetLines(); $_i < $_n; $_i++): ?>
5359
<div class="field additional">
5460
<label class="label" for="street_<?= /* @noEscape */ $_i + 1 ?>">
5561
<span><?= $block->escapeHtml(__('Street Address %1', $_i + 1)) ?></span>
@@ -67,7 +73,7 @@
6773
</div>
6874
</div>
6975

70-
<?php if ($this->helper(\Magento\Customer\Helper\Address::class)->isVatAttributeVisible()): ?>
76+
<?php if ($_address_helper->isVatAttributeVisible()): ?>
7177
<div class="field taxvat">
7278
<label class="label" for="vat_id">
7379
<span><?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('vat_id') ?></span>
@@ -77,38 +83,38 @@
7783
name="vat_id"
7884
value="<?= $block->escapeHtmlAttr($block->getAddress()->getVatId()) ?>"
7985
title="<?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('vat_id') ?>"
80-
class="input-text <?= $block->escapeHtmlAttr($this->helper(\Magento\Customer\Helper\Address::class)->getAttributeValidationClass('vat_id')) ?>"
86+
class="input-text <?= $block->escapeHtmlAttr($_address_helper->getAttributeValidationClass('vat_id')) ?>"
8187
id="vat_id">
8288
</div>
8389
</div>
8490
<?php endif; ?>
8591
<div class="field city required">
86-
<label class="label" for="city"><span><?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('city') ?></span></label>
92+
<label class="label" for="city"><span><?= /* @noEscape */ $_city ?></span></label>
8793
<div class="control">
8894
<input type="text"
8995
name="city"
9096
value="<?= $block->escapeHtmlAttr($block->getAddress()->getCity()) ?>"
9197
title="<?= $block->escapeHtmlAttr(__('City')) ?>"
92-
class="input-text <?= $block->escapeHtmlAttr($this->helper(\Magento\Customer\Helper\Address::class)->getAttributeValidationClass('city')) ?>"
98+
class="input-text <?= $block->escapeHtmlAttr($_address_helper->getAttributeValidationClass('city')) ?>"
9399
id="city">
94100
</div>
95101
</div>
96102
<div class="field region required">
97103
<label class="label" for="region_id">
98-
<span><?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('region') ?></span>
104+
<span><?= /* @noEscape */ $_region ?></span>
99105
</label>
100106
<div class="control">
101107
<select id="region_id" name="region_id"
102-
title="<?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('region') ?>"
108+
title="<?= /* @noEscape */ $_region ?>"
103109
class="validate-select region_id" <?= /* @noEscape */ !$block->getConfig('general/region/display_all') ? ' disabled="disabled"' : '' ?>>
104110
<option value=""><?= $block->escapeHtml(__('Please select a region, state or province.')) ?></option>
105111
</select>
106112
<input type="text"
107113
id="region"
108114
name="region"
109115
value="<?= $block->escapeHtmlAttr($block->getRegion()) ?>"
110-
title="<?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('region') ?>"
111-
class="input-text validate-not-number-first <?= $block->escapeHtmlAttr($this->helper(\Magento\Customer\Helper\Address::class)->getAttributeValidationClass('region')) ?>"<?= !$block->getConfig('general/region/display_all') ? ' disabled="disabled"' : '' ?>/>
116+
title="<?= /* @noEscape */ $_region ?>"
117+
class="input-text validate-not-number-first <?= $block->escapeHtmlAttr($_address_helper->getAttributeValidationClass('region')) ?>"<?= !$block->getConfig('general/region/display_all') ? ' disabled="disabled"' : '' ?>/>
112118
</div>
113119
</div>
114120
<div class="field zip required">
@@ -121,14 +127,14 @@
121127
value="<?= $block->escapeHtmlAttr($block->getAddress()->getPostcode()) ?>"
122128
title="<?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('postcode') ?>"
123129
id="zip"
124-
class="input-text validate-zip-international <?= $block->escapeHtmlAttr($this->helper(\Magento\Customer\Helper\Address::class)->getAttributeValidationClass('postcode')) ?>">
130+
class="input-text validate-zip-international <?= $block->escapeHtmlAttr($_address_helper->getAttributeValidationClass('postcode')) ?>">
125131
<div role="alert" class="message warning" style="display:none">
126132
<span></span>
127133
</div>
128134
</div>
129135
</div>
130136
<div class="field country required">
131-
<label class="label" for="country"><span><?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('country_id') ?></span></label>
137+
<label class="label" for="country"><span><?= /* @noEscape */ $_country_id ?></span></label>
132138
<div class="control">
133139
<?= $block->getCountryHtmlSelect() ?>
134140
</div>
@@ -189,14 +195,15 @@
189195
},
190196
"#country": {
191197
"regionUpdater": {
192-
"optionalRegionAllowed": <?= /* @noEscape */ $block->getConfig('general/region/display_all') ? 'true' : 'false' ?>,
198+
"optionalRegionAllowed":
199+
<?= /* @noEscape */ $block->getConfig('general/region/display_all') ? 'true' : 'false' ?>,
193200
"regionListId": "#region_id",
194201
"regionInputId": "#region",
195202
"postcodeId": "#zip",
196203
"form": "#form-validate",
197-
"regionJson": <?= /* @noEscape */ $this->helper(\Magento\Directory\Helper\Data::class)->getRegionJson() ?>,
204+
"regionJson": <?= /* @noEscape */ $_helper->getRegionJson() ?>,
198205
"defaultRegion": "<?= (int) $block->getRegionId() ?>",
199-
"countriesWithOptionalZip": <?= /* @noEscape */ $this->helper(\Magento\Directory\Helper\Data::class)->getCountriesWithOptionalZip(true) ?>
206+
"countriesWithOptionalZip": <?= /* @noEscape */ $_data_helper->getCountriesWithOptionalZip(true) ?>
200207
}
201208
}
202209
}

0 commit comments

Comments
 (0)