OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

Forums Forums OroPlatform OroPlatform – Programming Questions AddressBundle\Entity\AbstractAddress __toString()

This topic contains 2 replies, has 2 voices, and was last updated by  seddonm1 9 years, 10 months ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
    Topic
  • #33344

    seddonm1
    Participant

    Hi,
    I have returned to Oro after spending some time with the early betas and it is very much improved.

    I have found a scenario where I would like to be able to call a function similar to the javascript renderAddress version. I have seen you have this ‘todo’ action and was wondering if you have any improvements that are available?

    Thanks,
    Mike

    /**
    * Convert address to string
    * @todo: Address format must be used here
    *
    * @return string
    */
    public function __toString()
    {
    $data = array(
    $this->getFirstName(),
    $this->getLastName(),
    ‘,’,
    $this->getStreet(),
    $this->getStreet2(),
    $this->getCity(),
    $this->getUniversalRegion(),
    ‘,’,
    $this->getCountry(),
    $this->getPostalCode(),
    );

    $str = implode(‘ ‘, $data);
    $check = trim(str_replace(‘,’, ”, $str));
    return empty($check) ? ” : $str;
    }

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
    Replies
  • #33345

    Yevhen Shyshkin
    Participant

    Hello, seddonm1.

    Thank you for notice, we definitely need to improve this behavior.

    For now you can use AddressFormatter::format function to generate localized address format on backend, and twig filter oro_format_address or renderAddress macros in templates.

    #33346

    seddonm1
    Participant

    Thanks Yevhen.

Viewing 2 replies - 1 through 2 (of 2 total)

The forum ‘OroPlatform – Programming Questions’ is closed to new topics and replies.

Back to top