70 \
Magento\Framework\
Json\EncoderInterface $jsonEncoder,
71 \
Magento\Framework\
App\Cache\Type\Config $configCacheType,
74 \
Magento\Customer\Model\Session $customerSession,
81 $this->_customerSession = $customerSession;
91 $regionCollectionFactory,
92 $countryCollectionFactory,
104 parent::_prepareLayout();
107 if ($addressId = $this->
getRequest()->getParam(
'id')) {
109 $this->_address = $this->_addressRepository->getById($addressId);
110 if ($this->_address->getCustomerId() != $this->_customerSession->getCustomerId()) {
111 $this->_address =
null;
114 $this->_address =
null;
118 if ($this->_address ===
null || !$this->_address->getId()) {
119 $this->_address = $this->addressDataFactory->create();
121 $this->_address->setPrefix(
$customer->getPrefix());
122 $this->_address->setFirstname(
$customer->getFirstname());
123 $this->_address->setMiddlename(
$customer->getMiddlename());
124 $this->_address->setLastname(
$customer->getLastname());
125 $this->_address->setSuffix(
$customer->getSuffix());
128 $this->pageConfig->getTitle()->set($this->
getTitle());
130 if ($postedData = $this->_customerSession->getAddressFormData(
true)) {
131 $postedData[
'region'] = [
132 'region_id' => isset($postedData[
'region_id']) ? $postedData[
'region_id'] :
null,
133 'region' => $postedData[
'region'],
135 $this->dataObjectHelper->populateWithArray(
138 \
Magento\Customer\Api\Data\AddressInterface::class
153 ->createBlock(\
Magento\Customer\Block\Widget\Name::class)
156 return $nameBlock->toHtml();
184 if ($this->
getData(
'back_url')) {
185 return $this->
getData(
'back_url');
189 return $this->
getUrl(
'customer/address');
191 return $this->
getUrl(
'customer/account/');
202 return $this->_urlBuilder->getUrl(
203 'customer/address/formPost',
204 [
'_secure' =>
true,
'id' => $this->
getAddress()->getId()]
226 $street = $this->_address->getStreet();
227 return isset($street[$lineNumber - 1]) ? $street[$lineNumber - 1] :
'';
240 return parent::getCountryId();
251 return $region ===
null ?
'' : $region->getRegion();
262 return $region ===
null ? 0 : $region->getRegionId();
272 return count($this->
getCustomer()->getAddresses());
308 return (
bool)$this->
getAddress()->isDefaultBilling();
318 return (
bool)$this->
getAddress()->isDefaultShipping();
328 return $this->currentCustomer->getCustomer();
339 return $this->
getUrl(
'customer/address');
341 return $this->
getUrl(
'customer/account/');
353 return $this->_scopeConfig->getValue(
$path, \
Magento\Store\Model\ScopeInterface::SCOPE_STORE);
getData($key='', $index=null)
getStreetLine($lineNumber)
getCustomerAddressCount()
getUrl($route='', $params=[])
__construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Directory\Helper\Data $directoryHelper, \Magento\Framework\Json\EncoderInterface $jsonEncoder, \Magento\Framework\App\Cache\Type\Config $configCacheType, \Magento\Directory\Model\ResourceModel\Region\CollectionFactory $regionCollectionFactory, \Magento\Directory\Model\ResourceModel\Country\CollectionFactory $countryCollectionFactory, \Magento\Customer\Model\Session $customerSession, \Magento\Customer\Api\AddressRepositoryInterface $addressRepository, \Magento\Customer\Api\Data\AddressInterfaceFactory $addressDataFactory, \Magento\Customer\Helper\Session\CurrentCustomer $currentCustomer, \Magento\Framework\Api\DataObjectHelper $dataObjectHelper, array $data=[])
canSetAsDefaultShipping()