Skip to content

Commit 1c0549e

Browse files
committed
MC-13880: Revert MAGETWO-95816 as it does not correspond BC requirements
1 parent 8dfe26a commit 1c0549e

File tree

3 files changed

+6
-81
lines changed

3 files changed

+6
-81
lines changed

app/code/Magento/Sales/Model/Order/Address/Renderer.php

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
use Magento\Customer\Model\Address\Config as AddressConfig;
1010
use Magento\Framework\Event\ManagerInterface as EventManager;
1111
use Magento\Sales\Model\Order\Address;
12-
use Magento\Framework\Stdlib\StringUtils;
13-
use Magento\Framework\App\ObjectManager;
1412

1513
/**
1614
* Class Renderer used for formatting an order address
@@ -29,26 +27,18 @@ class Renderer
2927
*/
3028
protected $eventManager;
3129

32-
/**
33-
* @var StringUtils
34-
*/
35-
private $stringUtils;
36-
3730
/**
3831
* Constructor
3932
*
4033
* @param AddressConfig $addressConfig
4134
* @param EventManager $eventManager
42-
* @param StringUtils $stringUtils
4335
*/
4436
public function __construct(
4537
AddressConfig $addressConfig,
46-
EventManager $eventManager,
47-
StringUtils $stringUtils = null
38+
EventManager $eventManager
4839
) {
4940
$this->addressConfig = $addressConfig;
5041
$this->eventManager = $eventManager;
51-
$this->stringUtils = $stringUtils ?: ObjectManager::getInstance()->get(StringUtils::class);
5242
}
5343

5444
/**
@@ -68,50 +58,4 @@ public function format(Address $address, $type)
6858
$this->eventManager->dispatch('customer_address_format', ['type' => $formatType, 'address' => $address]);
6959
return $formatType->getRenderer()->renderArray($address->getData());
7060
}
71-
72-
/**
73-
* Detect an input string is Arabic
74-
*
75-
* @param string $subject
76-
* @return bool
77-
*/
78-
public function isArabic(string $subject): bool
79-
{
80-
return (preg_match('/\p{Arabic}/u', $subject) > 0);
81-
}
82-
83-
/**
84-
* Reverse text with Arabic characters
85-
*
86-
* @param string $string
87-
* @return string
88-
*/
89-
public function reverseArabicText($string)
90-
{
91-
$splitText = explode(' ', $string);
92-
for ($i = 0; $i < count($splitText); $i++) {
93-
if ($this->isArabic($splitText[$i])) {
94-
for ($j = $i + 1; $j < count($splitText); $j++) {
95-
$tmp = ($this->isArabic($splitText[$j]))
96-
? $this->stringUtils->strrev($splitText[$j]) : $splitText[$j];
97-
$splitText[$j] = ($this->isArabic($splitText[$i]))
98-
? $this->stringUtils->strrev($splitText[$i]) : $splitText[$i];
99-
$splitText[$i] = $tmp;
100-
}
101-
}
102-
}
103-
return implode(' ', $splitText);
104-
}
105-
106-
/**
107-
* Check and revert arabic text
108-
*
109-
* @param string $string
110-
* @return string
111-
*/
112-
public function processArabicText($string)
113-
{
114-
return ($this->isArabic($string))
115-
? $this->reverseArabicText($string) : $string;
116-
}
11761
}

app/code/Magento/Sales/Model/Order/Pdf/AbstractPdf.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -474,8 +474,7 @@ protected function insertOrder(&$page, $obj, $putOrderId = true)
474474
if ($value !== '') {
475475
$text = [];
476476
foreach ($this->string->split($value, 45, true, true) as $_value) {
477-
$text[] = ($this->addressRenderer->isArabic($_value))
478-
? $this->addressRenderer->reverseArabicText($_value) : $_value;
477+
$text[] = $_value;
479478
}
480479
foreach ($text as $part) {
481480
$page->drawText(strip_tags(ltrim($part)), 35, $this->y, 'UTF-8');
@@ -492,8 +491,7 @@ protected function insertOrder(&$page, $obj, $putOrderId = true)
492491
if ($value !== '') {
493492
$text = [];
494493
foreach ($this->string->split($value, 45, true, true) as $_value) {
495-
$text[] = ($this->addressRenderer->isArabic($_value))
496-
? $this->addressRenderer->reverseArabicText($_value) : $_value;
494+
$text[] = $_value;
497495
}
498496
foreach ($text as $part) {
499497
$page->drawText(strip_tags(ltrim($part)), 285, $this->y, 'UTF-8');

app/code/Magento/Sales/Model/Order/Pdf/Items/Invoice/DefaultInvoice.php

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
*/
66
namespace Magento\Sales\Model\Order\Pdf\Items\Invoice;
77

8-
use Magento\Framework\App\ObjectManager;
9-
use Magento\Sales\Model\Order\Address\Renderer;
10-
118
/**
129
* Sales Order Invoice Pdf default items renderer
1310
*/
@@ -20,11 +17,6 @@ class DefaultInvoice extends \Magento\Sales\Model\Order\Pdf\Items\AbstractItems
2017
*/
2118
protected $string;
2219

23-
/**
24-
* @var \Magento\Sales\Model\Order\Address\Renderer
25-
*/
26-
private $renderer;
27-
2820
/**
2921
* @param \Magento\Framework\Model\Context $context
3022
* @param \Magento\Framework\Registry $registry
@@ -35,8 +27,6 @@ class DefaultInvoice extends \Magento\Sales\Model\Order\Pdf\Items\AbstractItems
3527
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
3628
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
3729
* @param array $data
38-
* @param \Magento\Sales\Model\Order\Address\Renderer $renderer
39-
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
4030
*/
4131
public function __construct(
4232
\Magento\Framework\Model\Context $context,
@@ -47,8 +37,7 @@ public function __construct(
4737
\Magento\Framework\Stdlib\StringUtils $string,
4838
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
4939
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
50-
array $data = [],
51-
Renderer $renderer = null
40+
array $data = []
5241
) {
5342
$this->string = $string;
5443
parent::__construct(
@@ -61,7 +50,6 @@ public function __construct(
6150
$resourceCollection,
6251
$data
6352
);
64-
$this->renderer = $renderer ?: ObjectManager::getInstance()->get(Renderer::class);
6553
}
6654

6755
/**
@@ -78,16 +66,11 @@ public function draw()
7866
$lines = [];
7967

8068
// draw Product name
81-
$lines[0] = [
82-
[
83-
'text' => $this->string->split($this->renderer->processArabicText($item->getName()), 35, true, true),
84-
'feed' => 35
85-
]
86-
];
69+
$lines[0] = [['text' => $this->string->split($item->getName(), 35, true, true), 'feed' => 35]];
8770

8871
// draw SKU
8972
$lines[0][] = [
90-
'text' => $this->string->split($this->renderer->processArabicText($item->getSku($item)), 17),
73+
'text' => $this->string->split($this->getSku($item), 17),
9174
'feed' => 290,
9275
'align' => 'right',
9376
];

0 commit comments

Comments
 (0)