Skip to content

Commit ab4a25c

Browse files
authored
Merge pull request #26 from logeecom/master
Release v1.4.1
2 parents 025a3a9 + 8293a8b commit ab4a25c

File tree

16 files changed

+202
-84
lines changed

16 files changed

+202
-84
lines changed

Packlink/Bootstrap/Bootstrap.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
use Packlink\Services\BusinessLogic\ShopShippingMethodService as ConcreteShopShippingMethodService;
3636
use Packlink\BusinessLogic\SystemInformation\SystemInfoService as SystemInfoInterface;
3737
use Packlink\Services\BusinessLogic\SystemInfoService;
38+
use Packlink\Services\BusinessLogic\WarehouseCountryService;
3839
use Packlink\Services\Infrastructure\LoggerService;
3940

4041
class Bootstrap extends BootstrapComponent
@@ -124,6 +125,13 @@ function () {
124125
]);
125126
}
126127
);
128+
129+
ServiceRegister::registerService(
130+
\Packlink\BusinessLogic\Country\WarehouseCountryService::CLASS_NAME,
131+
function () {
132+
return WarehouseCountryService::getInstance();
133+
}
134+
);
127135
}
128136

129137
/**

Packlink/Controllers/Backend/PacklinkConfiguration.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,9 @@ protected function getUrls()
227227
'deactivateShopShippingMethods'
228228
),
229229
'getCurrencyDetailsUrl' => Url::getBackendUrl('PacklinkSystemInfoController', 'get'),
230-
'systemId' => (string)Shop::getDefaultShop()->getId()
230+
'systemId' => (string)Shop::getDefaultShop()->getId(),
231+
'enqueue' => Url::getBackendUrl('PacklinkManualRefreshController', 'refresh'),
232+
'getTaskStatus' => Url::getBackendUrl('PacklinkManualRefreshController', 'getTaskStatus')
231233
],
232234
'edit-service' => [
233235
'getServiceUrl' => $shopUrl . Url::getBackendUrl('PacklinkShippingMethod', 'getShippingMethod'),
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
use Packlink\BusinessLogic\Controllers\ManualRefreshController;
4+
5+
class Shopware_Controllers_Backend_PacklinkManualRefreshController extends Enlight_Controller_Action
6+
{
7+
public function getWhitelistedCSRFActions()
8+
{
9+
return ['refresh', 'getTaskStatus'];
10+
}
11+
12+
13+
public function refreshAction()
14+
{
15+
$controller = new ManualRefreshController();
16+
17+
$this->View()->assign(['response' => $controller->enqueueUpdateTask()]);
18+
}
19+
20+
public function getTaskStatusAction()
21+
{
22+
$controller = new ManualRefreshController();
23+
24+
$this->View()->assign(['response' => $controller->getTaskStatus()]);
25+
}
26+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{block name="get_task_status"}
2+
{if isset($response)}
3+
{$response|@json_encode}
4+
{/if}
5+
{/block}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{block name="refresh"}
2+
{if isset($response)}
3+
{$response|@json_encode}
4+
{/if}
5+
{/block}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
namespace Packlink\Services\BusinessLogic;
4+
5+
use Doctrine\DBAL\Connection;
6+
use Packlink\BusinessLogic\Country\WarehouseCountryService as CoreService;
7+
8+
/**
9+
* Class WarehouseCountryService
10+
*
11+
* @package Packlink\Services\BusinessLogic
12+
*/
13+
class WarehouseCountryService extends CoreService
14+
{
15+
/**
16+
* @param $associative
17+
*
18+
* @return \Packlink\BusinessLogic\Country\Country[]
19+
*
20+
* @throws \Packlink\BusinessLogic\DTO\Exceptions\FrontDtoNotRegisteredException
21+
* @throws \Packlink\BusinessLogic\DTO\Exceptions\FrontDtoValidationException
22+
*/
23+
public function getSupportedCountries($associative = true)
24+
{
25+
$countries = $this->getBrandConfigurationService()->get()->warehouseCountries;
26+
/** @var Connection $connection */
27+
$connection = Shopware()->Container()->get('dbal_connection');
28+
$sql = "SELECT id, countryiso FROM s_core_countries WHERE active = 1";
29+
$activeCountries = $connection->fetchAllAssociative($sql);
30+
$intersectedCountries = [];
31+
32+
foreach ($activeCountries as $country) {
33+
if (array_key_exists($country['countryiso'], $countries)) {
34+
$intersectedCountries[] = $countries[$country['countryiso']];
35+
}
36+
}
37+
38+
$result = $this->formatCountries($intersectedCountries);
39+
40+
return $associative ? $result : array_values($result);
41+
}
42+
}

Packlink/Subscribers/ControllerPath.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public static function getSubscribedEvents()
5353
'Enlight_Controller_Dispatcher_ControllerPath_Frontend_PacklinkLocations' => 'onGetControllerPromotion',
5454
'Enlight_Controller_Dispatcher_ControllerPath_Frontend_PacklinkDropoff' => 'onGetControllerPromotion',
5555
'Enlight_Controller_Dispatcher_ControllerPath_Backend_PacklinkSystemInfoController' => 'onGetControllerPromotion',
56+
'Enlight_Controller_Dispatcher_ControllerPath_Backend_PacklinkManualRefreshController' => 'onGetControllerPromotion',
5657
];
5758
}
5859

Packlink/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "packlink/shopware",
33
"description": "Packlink Shipping Shopware plugin",
44
"type": "library",
5-
"version": "1.3.7",
5+
"version": "1.4.1",
66
"repositories": [
77
{
88
"type": "vcs",
@@ -13,7 +13,7 @@
1313
"minimum-stability": "dev",
1414
"require": {
1515
"php": ">=5.6",
16-
"packlink/integration-core": "3.3.18",
16+
"packlink/integration-core": "3.5.1",
1717
"ext-json": "*",
1818
"ext-curl": "*",
1919
"ext-zip": "*",

0 commit comments

Comments
 (0)