Esempio n. 1
0
 /**
  * Represent customer address in 'online' format.
  *
  * @param \Magento\Customer\Api\Data\AddressInterface $address
  * @return string
  */
 public function getAddressAsString(\Magento\Customer\Api\Data\AddressInterface $address)
 {
     $formatTypeRenderer = $this->_addressHelper->getFormatTypeRenderer('oneline');
     $result = '';
     if ($formatTypeRenderer) {
         $result = $formatTypeRenderer->renderArray($this->addressMapper->toFlatArray($address));
     }
     return $this->escapeHtml($result);
 }
Esempio n. 2
0
 /**
  * Represent customer address in HTML format.
  *
  * @param \Magento\Customer\Api\Data\AddressInterface $address
  * @return string
  */
 public function getAddressAsHtml(\Magento\Customer\Api\Data\AddressInterface $address)
 {
     $formatTypeRenderer = $this->_customerAddressHelper->getFormatTypeRenderer('html');
     $result = '';
     if ($formatTypeRenderer) {
         $result = $formatTypeRenderer->renderArray($this->addressMapper->toFlatArray($address));
     }
     return $result;
 }
Esempio n. 3
0
 /**
  * Represent customer address in 'online' format.
  *
  * @param \Magento\Customer\Service\V1\Data\Address $addressData
  * @return string
  */
 public function getAddressAsString($addressData)
 {
     $formatTypeRenderer = $this->_addressHelper->getFormatTypeRenderer('oneline');
     $result = '';
     if ($formatTypeRenderer) {
         $result = $formatTypeRenderer->renderArray(AddressConverter::toFlatArray($addressData));
     }
     return $this->escapeHtml($result);
 }
Esempio n. 4
0
 /**
  * @return string|null
  */
 public function getBillingAddressHtml()
 {
     try {
         $address = $this->_addressService->getAddress($this->getCustomer()->getDefaultBilling());
     } catch (NoSuchEntityException $e) {
         return __('The customer does not have default billing address.');
     }
     return $this->_addressHelper->getFormatTypeRenderer('html')->renderArray(AddressConverter::toFlatArray($address));
 }
Esempio n. 5
0
 /**
  * Represent customer address in HTML format.
  *
  * @param \Magento\Customer\Service\V1\Data\Address $addressData
  * @return string
  */
 public function getAddressAsHtml($addressData)
 {
     $formatTypeRenderer = $this->_customerAddressHelper->getFormatTypeRenderer('html');
     $result = '';
     if ($formatTypeRenderer) {
         $result = $formatTypeRenderer->renderArray(AddressConverter::toFlatArray($addressData));
     }
     return $result;
 }
Esempio n. 6
0
 /**
  * Retrieve billing address html
  *
  * @return \Magento\Framework\Phrase|string
  */
 public function getBillingAddressHtml()
 {
     try {
         $address = $this->accountManagement->getDefaultBillingAddress($this->getCustomer()->getId());
     } catch (NoSuchEntityException $e) {
         return __('The customer does not have default billing address.');
     }
     if ($address === null) {
         return __('The customer does not have default billing address.');
     }
     return $this->addressHelper->getFormatTypeRenderer('html')->renderArray($this->addressMapper->toFlatArray($address));
 }
Esempio n. 7
0
 /**
  * Format the given address to the given type
  *
  * @param AddressInterface $address
  * @param string $type
  * @return string
  */
 public function format(AddressInterface $address, $type)
 {
     return $this->_addressHelper->getFormatTypeRenderer($type)->renderArray($this->addressMapper->toFlatArray($address));
 }
Esempio n. 8
0
 /**
  * @param string $code
  * @param \Magento\Customer\Block\Address\Renderer\RendererInterface|null $result
  * @dataProvider getFormatTypeRendererDataProvider
  */
 public function testGetFormatTypeRenderer($code, $result)
 {
     $this->addressConfig->expects($this->once())->method('getFormatByCode')->with($code)->will($this->returnValue(new \Magento\Framework\Object(!is_null($result) ? array('renderer' => $result) : array())));
     $this->assertEquals($result, $this->helper->getFormatTypeRenderer($code));
 }
Esempio n. 9
0
 /**
  * Format the given address to the given type
  *
  * @param Address $address
  * @param string $type
  * @return string
  */
 public function format(Address $address, $type)
 {
     return $this->_addressHelper->getFormatTypeRenderer($type)->renderArray(AddressConverter::toFlatArray($address));
 }