Skip to content

Commit

Permalink
Revert deletion of a function
Browse files Browse the repository at this point in the history
  • Loading branch information
kostandin-logeecom committed Apr 8, 2020
1 parent d668fe0 commit 74f7d0f
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 97 deletions.
7 changes: 5 additions & 2 deletions Packlink/Controllers/Backend/PacklinkConfiguration.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?php

use Logeecom\Infrastructure\ServiceRegister;
use Packlink\BusinessLogic\Country\CountryService;
use Packlink\Controllers\Common\CanInstantiateServices;

class Shopware_Controllers_Backend_PacklinkConfiguration extends Enlight_Controller_Action
{
use CanInstantiateServices;

/**
* List of help URLs for different country codes.
*
Expand Down Expand Up @@ -39,9 +40,11 @@ class Shopware_Controllers_Backend_PacklinkConfiguration extends Enlight_Control
public function indexAction()
{
$userInfo = $this->getConfigService()->getUserInfo();
/** @var \Packlink\BusinessLogic\Country\CountryService $countryService */
$countryService = ServiceRegister::getService(CountryService::CLASS_NAME);

$urlKey = 'EN';
if ($userInfo && in_array($userInfo->country, ['ES', 'DE', 'FR', 'IT'], true)) {
if ($userInfo && $countryService->isBaseCountry($userInfo->country)) {
$urlKey = $userInfo->country;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public function indexAction()
Response::json([], 400);
}

/** @noinspection PhpUndefinedVariableInspection */
$details = [
'orderCost' => $order->getInvoiceShipping(),
'cost' => $orderDetails->getShippingCost(),
Expand All @@ -53,10 +52,8 @@ public function indexAction()
$details['trackingUrl'] = $orderDetails->getCarrierTrackingUrl();
}

$country = $this->getUserCountry();

if ($details['reference']) {
$details['referenceUrl'] = Reference::getUrl($country, $details['reference']);
$details['referenceUrl'] = $orderDetails->getShipmentUrl();
}

try {
Expand All @@ -75,7 +72,6 @@ public function indexAction()
Logger::logWarning("Failed to retrieve dispatch because: {$e->getMessage()}");
}

/** @noinspection PhpUndefinedVariableInspection */
Response::json($details);
}

Expand Down
16 changes: 15 additions & 1 deletion Packlink/Migrations/Scripts/migration.v.0.9.0.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
use Logeecom\Infrastructure\ORM\Exceptions\RepositoryNotRegisteredException;
use Logeecom\Infrastructure\ORM\RepositoryRegistry;
use Logeecom\Infrastructure\ServiceRegister;
use Logeecom\Infrastructure\TaskExecution\Exceptions\QueueStorageUnavailableException;
use Logeecom\Infrastructure\TaskExecution\QueueItem;
use Logeecom\Infrastructure\TaskExecution\QueueService;
use Packlink\BusinessLogic\Country\CountryService;
use Packlink\BusinessLogic\OrderShipmentDetails\Models\OrderShipmentDetails;
use Packlink\BusinessLogic\Scheduler\Models\HourlySchedule;
use Packlink\BusinessLogic\Scheduler\Models\Schedule;
Expand Down Expand Up @@ -51,6 +53,17 @@
$orderShipmentDetailsRepository = RepositoryRegistry::getRepository(OrderShipmentDetails::getClassName());
$orderSendDraftRepository = RepositoryRegistry::getRepository(OrderSendDraftTaskMap::getClassName());

/** @var CountryService $countryService */
$countryService = ServiceRegister::getService(CountryService::CLASS_NAME);

$userInfo = $configuration->getUserInfo();
$userDomain = 'com';
if ($userInfo && $countryService->isBaseCountry($userInfo->country)) {
$userDomain = strtolower($userInfo->country);
}

$baseShipmentUrl = "https://pro.packlink.$userDomain/private/shipments/";

/** @var BaseEntity $entity */
foreach ($entities as $entity) {
$orderShipmentData = json_decode($entity->getData(), true);
Expand All @@ -63,6 +76,7 @@
unset($orderShipmentData['taskId']);
$orderShipmentDetails = OrderShipmentDetails::fromArray($orderShipmentData);
$orderShipmentDetails->setOrderId((string)$orderShipmentData['orderId']);
$orderShipmentDetails->setShipmentUrl($baseShipmentUrl . $orderShipmentDetails->getReference());
$orderShipmentDetailsRepository->update($orderShipmentDetails);
}
}
Expand All @@ -73,7 +87,7 @@

Logger::logInfo('Migration successful');
} catch (RepositoryNotRegisteredException $e) {
} catch (\Logeecom\Infrastructure\TaskExecution\Exceptions\QueueStorageUnavailableException $e) {
} catch (QueueStorageUnavailableException $e) {
Logger::logError("V0.9.0 update script failed because: {$e->getMessage()}");

return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
text-indent: 0 !important;
}

.lp-input-wrapper > .input > input:focus + .label,
Expand Down
8 changes: 1 addition & 7 deletions Packlink/Subscribers/OrderListHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Logeecom\Infrastructure\ServiceRegister;
use Packlink\BusinessLogic\Order\OrderService;
use Packlink\BusinessLogic\OrderShipmentDetails\OrderShipmentDetailsService;
use Packlink\Utilities\Reference;

class OrderListHandler implements SubscriberInterface
{
Expand Down Expand Up @@ -45,7 +44,6 @@ public function extendOrderList(Enlight_Hook_HookArgs $args)
return;
}

$userCountry = $this->getUserCountry();
$return = $args->getReturn();

/** @var \Packlink\BusinessLogic\OrderShipmentDetails\OrderShipmentDetailsService $orderShipmentDetailsService */
Expand All @@ -54,11 +52,7 @@ public function extendOrderList(Enlight_Hook_HookArgs $args)
foreach ($return['data'] as $index => $order) {
$orderDetails = $orderShipmentDetailsService->getDetailsByOrderId((string)$order['id']);
if ($orderDetails !== null && $orderDetails->getReference()) {
$return['data'][$index]['plReferenceUrl'] = Reference::getUrl(
$userCountry,
$orderDetails->getReference()
);

$return['data'][$index]['plReferenceUrl'] = $orderDetails->getShipmentUrl();
$return['data'][$index]['plIsDeleted'] = $orderDetails->isDeleted();

$orderService = $this->getOrderService();
Expand Down
25 changes: 0 additions & 25 deletions Packlink/Utilities/Reference.php

This file was deleted.

2 changes: 1 addition & 1 deletion Packlink/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"minimum-stability": "dev",
"require": {
"php": ">=5.6",
"packlink/integration-core": "2.0.1",
"packlink/integration-core": "2.0.*",
"ext-json": "*",
"ext-curl": "*",
"ext-zip": "*",
Expand Down
112 changes: 56 additions & 56 deletions Packlink/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added PluginInstallation/0.9.0/Packlink.zip
Binary file not shown.
3 changes: 3 additions & 0 deletions PluginInstallation/0.9.0/Release notes 0.9.0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Updated to the Packlink Integrations Core v2.0.0 (system improvements and code optimization).
- Added task cleanup.
- Packlink now supports more countries.

0 comments on commit 74f7d0f

Please sign in to comment.