@@ -46,7 +46,9 @@ abstract class AbstractPdf extends \Magento\Framework\DataObject
46
46
* Predefined constants
47
47
*/
48
48
public const XML_PATH_SALES_PDF_INVOICE_PUT_ORDER_ID = 'sales_pdf/invoice/put_order_id ' ;
49
+
49
50
public const XML_PATH_SALES_PDF_SHIPMENT_PUT_ORDER_ID = 'sales_pdf/shipment/put_order_id ' ;
51
+
50
52
public const XML_PATH_SALES_PDF_CREDITMEMO_PUT_ORDER_ID = 'sales_pdf/creditmemo/put_order_id ' ;
51
53
52
54
/**
@@ -133,7 +135,7 @@ abstract public function getPdf();
133
135
/**
134
136
* @var Magento\Tax\Helper\Data
135
137
*/
136
- protected $ taxHelper ;
138
+ private $ taxHelper ;
137
139
138
140
/**
139
141
* @var array $pageSettings
@@ -156,8 +158,11 @@ abstract public function getPdf();
156
158
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
157
159
* @param \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation
158
160
* @param \Magento\Sales\Model\Order\Address\Renderer $addressRenderer
159
- * @param \Magento\Tax\Helper\Data $taxHelper
161
+ * @param TaxHelper $taxHelper
160
162
* @param array $data
163
+ * @param Database $fileStorageDatabase
164
+ * @param RtlTextHandler|null $rtlTextHandler
165
+ * @param Image $image
161
166
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
162
167
*/
163
168
public function __construct (
@@ -171,8 +176,11 @@ public function __construct(
171
176
\Magento \Framework \Stdlib \DateTime \TimezoneInterface $ localeDate ,
172
177
\Magento \Framework \Translate \Inline \StateInterface $ inlineTranslation ,
173
178
\Magento \Sales \Model \Order \Address \Renderer $ addressRenderer ,
174
- \Magento \Tax \Helper \Data $ taxHelper ,
175
- array $ data = []
179
+ TaxHelper $ taxHelper = null ,
180
+ array $ data = [],
181
+ Database $ fileStorageDatabase = null ,
182
+ ?RtlTextHandler $ rtlTextHandler = null ,
183
+ ?Image $ image = null
176
184
) {
177
185
$ this ->addressRenderer = $ addressRenderer ;
178
186
$ this ->_paymentData = $ paymentData ;
@@ -185,46 +193,13 @@ public function __construct(
185
193
$ this ->_pdfTotalFactory = $ pdfTotalFactory ;
186
194
$ this ->_pdfItemsFactory = $ pdfItemsFactory ;
187
195
$ this ->inlineTranslation = $ inlineTranslation ;
188
- $ this ->taxHelper = $ taxHelper ;
189
-
190
- // Initialize optional dependencies using ObjectManager if not provided
191
- $ objectManager = ObjectManager::getInstance ();
192
- $ this ->fileStorageDatabase = $ objectManager ->get (Database::class);
193
- $ this ->rtlTextHandler = $ objectManager ->get (RtlTextHandler::class);
194
- $ this ->image = $ objectManager ->get (Image::class);
195
-
196
+ $ this ->taxHelper = $ taxHelper ?: ObjectManager::getInstance ()->get (TaxHelper::class);
197
+ $ this ->fileStorageDatabase = $ fileStorageDatabase ?: ObjectManager::getInstance ()->get (Database::class);
198
+ $ this ->rtlTextHandler = $ rtlTextHandler ?: ObjectManager::getInstance ()->get (RtlTextHandler::class);
199
+ $ this ->image = $ image ?: ObjectManager::getInstance ()->get (Image::class);
196
200
parent ::__construct ($ data );
197
201
}
198
202
199
- /**
200
- * Set optional dependencies
201
- *
202
- * @param Database|null $fileStorageDatabase
203
- * @param RtlTextHandler|null $rtlTextHandler
204
- * @param Image|null $image
205
- * @return void
206
- */
207
- public function setOptionalDependencies (
208
- Database $ fileStorageDatabase = null ,
209
- RtlTextHandler $ rtlTextHandler = null ,
210
- Image $ image = null
211
-
212
- )
213
- {
214
- if ($ fileStorageDatabase ) {
215
- $ this ->fileStorageDatabase = $ fileStorageDatabase ;
216
- }
217
- if ($ rtlTextHandler ) {
218
- $ this ->rtlTextHandler = $ rtlTextHandler ;
219
- }
220
- if ($ image ) {
221
- $ this ->image = $ image ;
222
- }
223
-
224
- }
225
-
226
-
227
-
228
203
/**
229
204
* Returns the total width in points of the string using the specified font and size.
230
205
*
@@ -645,7 +620,8 @@ protected function insertOrder(&$page, $obj, $putOrderId = true)
645
620
$ totalShippingChargesText .= $ order ->formatPriceTxt ($ order ->getShippingAmount ());
646
621
}
647
622
648
- if ($ this ->taxHelper ->displayShippingBothPrices () && $ order ->getShippingInclTax () != $ order ->getShippingAmount ()) {
623
+ if ($ this ->taxHelper ->displayShippingBothPrices ()
624
+ && $ order ->getShippingInclTax () != $ order ->getShippingAmount ()) {
649
625
$ totalShippingChargesText .= "(Incl. Tax " . $ order ->getShippingInclTax () . ") " ;
650
626
}
651
627
$ totalShippingChargesText .= ") " ;
0 commit comments