Skip to content

Commit

Permalink
Added address template as argument
Browse files Browse the repository at this point in the history
  • Loading branch information
jokeputs committed Sep 29, 2017
1 parent 9c14af7 commit 58d96ae
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions app/code/Magento/Store/Model/Address/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
*/
class Renderer
{
const DEFAULT_TEMPLATE = "{{var name}}\n" .
"{{var street_line1}}\n" .
"{{depend street_line2}}{{var street_line2}}\n{{/depend}}" .
"{{depend city}}{{var city}},{{/depend}} {{var region}} {{depend postcode}}{{var postcode}},{{/depend}}\n" .
"{{var country}}";

/**
* @var EventManager
*/
Expand All @@ -25,18 +31,26 @@ class Renderer
*/
protected $filterManager;

/**
* @var string
*/
private $template;

/**
* Constructor
*
* @param EventManager $eventManager
* @param FilterManager $filterManager
* @param string $template
*/
public function __construct(
EventManager $eventManager,
FilterManager $filterManager
FilterManager $filterManager,
$template = self::DEFAULT_TEMPLATE
) {
$this->eventManager = $eventManager;
$this->filterManager = $filterManager;
$this->template = $template;
}

/**
Expand All @@ -50,9 +64,7 @@ public function format(DataObject $storeInfo, $type = 'html')
{
$this->eventManager->dispatch('store_address_format', ['type' => $type, 'store_info' => $storeInfo]);
$address = $this->filterManager->template(
"{{var name}}\n{{var street_line1}}\n{{depend street_line2}}{{var street_line2}}\n{{/depend}}" .
"{{depend city}}{{var city}},{{/depend}} {{var region}} {{depend postcode}}{{var postcode}},{{/depend}}\n" .
"{{var country}}",
$this->template,
['variables' => $storeInfo->getData()]
);

Expand Down

0 comments on commit 58d96ae

Please sign in to comment.