PluginProbe
Packeta / 2.1
Packeta v2.1
2.3.2 2.3.1 trunk 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3.0 1.3.1 1.3.2 1.4 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 All 56 releases
← All changes | src/Packetery/Module/Order/GridExtender.php +21 -43 trunk2.1 View file →
@@ -19,9 +19,8 @@
19 19 use Packetery\Module\Framework\WpAdapter;
20 20 use Packetery\Module\Log\Purger;
21 21 use Packetery\Module\ModuleHelper;
22 22 use Packetery\Module\Plugin;
23 -use Packetery\Module\WcLogger;
24 23 use Packetery\Nette\Http\Request;
25 24 use WC_Order;
26 25
27 26 use function esc_html;
@@ -108,13 +107,8 @@
108 107 */
109 108 private $packetStatusResolver;
110 109
111 110 /**
112 - * @var Form
113 - */
114 - private $orderForm;
115 -
116 - /**
117 111 * GridExtender constructor.
118 112 *
119 113 * @param CoreHelper $coreHelper CoreHelper.
120 114 * @param Engine $latteEngine Latte Engine.
@@ -138,10 +132,9 @@
138 132 CarrierOptionsFactory $carrierOptionsFactory,
139 133 WpAdapter $wpAdapter,
140 134 ModuleHelper $moduleHelper,
141 135 SizeFactory $sizeFactory,
142 - PacketStatusResolver $packetStatusResolver,
143 - Form $orderForm
136 + PacketStatusResolver $packetStatusResolver
144 137 ) {
145 138 $this->coreHelper = $coreHelper;
146 139 $this->latteEngine = $latteEngine;
147 140 $this->httpRequest = $httpRequest;
@@ -152,24 +145,18 @@
152 145 $this->wpAdapter = $wpAdapter;
153 146 $this->moduleHelper = $moduleHelper;
154 147 $this->sizeFactory = $sizeFactory;
155 148 $this->packetStatusResolver = $packetStatusResolver;
156 - $this->orderForm = $orderForm;
157 149 }
158 150
159 151 /**
160 152 * Adds custom filtering links to order grid.
161 153 *
162 - * @param string[]|mixed $htmlLinks Array of html links.
154 + * @param string[] $htmlLinks Array of html links.
163 155 *
164 - * @return string[]|mixed
156 + * @return string[]
165 157 */
166 - public function addFilterLinks( $htmlLinks ) {
167 - if ( ! is_array( $htmlLinks ) ) {
168 - WcLogger::logArgumentTypeError( __METHOD__, 'htmlLinks', 'array', $htmlLinks );
169 -
170 - return $htmlLinks;
171 - }
158 + public function addFilterLinks( array $htmlLinks ): array {
172 159 $linkConfig = new GridLinksConfig(
173 160 $this->wpAdapter->__( 'Packeta orders to submit', 'packeta' ),
174 161 $this->wpAdapter->__( 'Packeta orders to print', 'packeta' ),
175 162 $this->wpAdapter->__( 'Run Packeta wizard', 'packeta' )
@@ -353,14 +340,14 @@
353 340 break;
354 341 case 'packetery_destination':
355 342 $pickupPoint = $order->getPickupPoint();
356 343 if ( $pickupPoint !== null ) {
357 - $pointPlaceOrName = $pickupPoint->getPlace() ?? $pickupPoint->getName();
358 - $pointId = $pickupPoint->getId();
344 + $pointName = $pickupPoint->getName();
345 + $pointId = $pickupPoint->getId();
359 346 if ( ! $order->isExternalCarrier() ) {
360 - echo esc_html( "$pointPlaceOrName ($pointId)" );
347 + echo esc_html( "$pointName ($pointId)" );
361 348 } else {
362 - echo esc_html( $pointPlaceOrName );
349 + echo esc_html( $pointName );
363 350 }
364 351
365 352 break;
366 353 }
@@ -431,11 +418,8 @@
431 418 ],
432 419 admin_url( 'admin.php' )
433 420 );
434 421
435 - $invalidFields = $this->orderForm->getInvalidFieldsFromValidationResult( $this->orderValidator->validate( $order ) );
436 - $invalidFieldsMessage = $this->orderForm->getInvalidFieldsMessageFromValidationResult( $invalidFields, $order );
437 -
438 422 $this->latteEngine->render(
439 423 PACKETERY_PLUGIN_DIR . '/template/order/grid-column-packetery.latte',
440 424 [
441 425 'order' => $order,
@@ -442,10 +426,9 @@
442 426 'dimensions' => $this->sizeFactory->createSizeInSetDimensionUnit( $order ),
443 427 'orderIsSubmittable' => $this->orderValidator->isValid( $order ),
444 428 'isPossibleExtendPacketPickUpDate' => $order->isPossibleExtendPacketPickUpDate(),
445 429 'storedUntil' => $this->coreHelper->getStringFromDateTime( $order->getStoredUntil(), CoreHelper::DATEPICKER_FORMAT ),
446 - 'orderWarningFields' => $invalidFields,
447 - 'invalidFieldsMessage' => $invalidFieldsMessage,
430 + 'orderWarningFields' => Form::getInvalidFieldsFromValidationResult( $this->orderValidator->validate( $order ) ),
448 431 'packetSubmitUrl' => $packetSubmitUrl,
449 432 'packetCancelLink' => $packetCancelLink,
450 433 'printLink' => $printLink,
451 434 'helper' => $this->coreHelper,
@@ -452,19 +435,20 @@
452 435 'datePickerFormat' => CoreHelper::DATEPICKER_FORMAT,
453 436 'logPurgerDatetimeModifier' => $this->wpAdapter->getOption( Purger::PURGER_OPTION_NAME, Purger::PURGER_MODIFIER_DEFAULT ),
454 437 'packetDeliverOn' => $this->coreHelper->getStringFromDateTime( $order->getDeliverOn(), CoreHelper::DATEPICKER_FORMAT ),
455 438 'translations' => [
456 - 'printLabel' => __( 'Print label', 'packeta' ),
457 - 'setAdditionalPacketInfo' => __( 'Set additional packet information', 'packeta' ),
458 - 'setStoredUntil' => __( 'Set the pickup date extension', 'packeta' ),
459 - 'submitToPacketa' => __( 'Submit to Packeta', 'packeta' ),
439 + 'printLabel' => __( 'Print label', 'packeta' ),
440 + 'setAdditionalPacketInfo' => __( 'Set additional packet information', 'packeta' ),
441 + 'setStoredUntil' => __( 'Set the pickup date extension', 'packeta' ),
442 + 'packetSubmissionNotPossible' => __( 'It is not possible to submit the shipment because all the information required for this shipment is not filled.', 'packeta' ),
443 + 'submitToPacketa' => __( 'Submit to Packeta', 'packeta' ),
460 444 // translators: %s: Order number.
461 - 'reallyCancelPacketHeading' => sprintf( __( 'Order #%s', 'packeta' ), $order->getCustomNumber() ),
445 + 'reallyCancelPacketHeading' => sprintf( __( 'Order #%s', 'packeta' ), $order->getCustomNumber() ),
462 446 // translators: %s: Packet number.
463 - 'reallyCancelPacket' => sprintf( __( 'Do you really wish to cancel parcel number %s?', 'packeta' ), (string) $order->getPacketId() ),
447 + 'reallyCancelPacket' => sprintf( __( 'Do you really wish to cancel parcel number %s?', 'packeta' ), (string) $order->getPacketId() ),
464 448
465 - 'cancelPacket' => __( 'Cancel packet', 'packeta' ),
466 - 'lastErrorFromApi' => __( 'Last error from Packeta API', 'packeta' ),
449 + 'cancelPacket' => __( 'Cancel packet', 'packeta' ),
450 + 'lastErrorFromApi' => __( 'Last error from Packeta API', 'packeta' ),
467 451 ],
468 452 ]
469 453 );
470 454
@@ -488,19 +472,13 @@
488 472
489 473 /**
490 474 * Add order list columns.
491 475 *
492 - * @param string[]|mixed $columns Order list columns.
476 + * @param string[] $columns Order list columns.
493 477 *
494 - * @return string[]|mixed All columns.
478 + * @return string[] All columns.
495 479 */
496 - public function addOrderListColumns( $columns ) {
497 - if ( ! is_array( $columns ) ) {
498 - WcLogger::logArgumentTypeError( __METHOD__, 'columns', 'array', $columns );
499 -
500 - return $columns;
501 - }
502 -
480 + public function addOrderListColumns( array $columns ): array {
503 481 $newColumns = array();
504 482
505 483 foreach ( $columns as $columnName => $columnInfo ) {
506 484 $newColumns[ $columnName ] = $columnInfo;