-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/3.1.3' into master-sw65
- Loading branch information
Showing
10 changed files
with
209 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,20 @@ | ||
# Shopware | ||
Voor de handleiding ga naar https://postnl.github.io/shopware | ||
# PostNL integratie voor Shopware 6 | ||
|
||
## Welke versie moet ik gebruiken? | ||
Vanwege breaking changes in Shopware zijn we genoodzaakt om voor bepaalde Shopware versies een nieuwe major versie van de plugin uit te brengen. Zie onderstaande tabel welke versie van de plugin geschikt is voor jouw Shopware installatie. | ||
|
||
| Shopware | Plugin | | ||
|-------------------|------------| | ||
| 6.5 vanaf 6.5.2.0 | Versie 3.x | | ||
| 6.4 vanaf 6.4.1.0 | Versie 2.x | | ||
|
||
#### Laatste versies | ||
![Shopware 6.5](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fgithub.com%2Fpostnl%2Fshopware%2Fraw%2Fmaster-sw65%2Fcomposer.json&query=version&prefix=Versie%20&style=flat-square&label=Shopware%206.5&color=ed7000) | ||
![Shopware 6.4](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fgithub.com%2Fpostnl%2Fshopware%2Fraw%2Fmaster-sw64%2Fcomposer.json&query=version&prefix=Versie%20&style=flat-square&label=Shopware%206.4&color=ed7000) | ||
|
||
## Installatie | ||
De installatie handleiding is te vinden op https://postnl.github.io/shopware | ||
|
||
Installatie via Composer of door deze repository te clonen is mogelijk, maar wordt niet officieel ondersteunt. Hiervoor zijn extra stappen nodig die niet in de handleiding worden beschreven. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PostNL\Shopware6\Service\PostNL; | ||
|
||
use PostNL\Shopware6\Service\Shopware\PluginService; | ||
use Shopware\Core\Framework\Context; | ||
|
||
class VersionProvider | ||
{ | ||
protected string $shopwareVersion; | ||
protected string $shopwareRootPath; | ||
protected PluginService $pluginService; | ||
|
||
private array $composerPackages = []; | ||
|
||
public function __construct( | ||
string $shopwareVersion, | ||
string $shopwareRootPath, | ||
PluginService $pluginService, | ||
) | ||
{ | ||
$this->shopwareVersion = $shopwareVersion; | ||
$this->shopwareRootPath = $shopwareRootPath; | ||
$this->pluginService = $pluginService; | ||
} | ||
|
||
public function getAllAsString(Context $context): string | ||
{ | ||
$versions = []; | ||
|
||
foreach ($this->getAll($context) as $key => $version) { | ||
$versions[] = sprintf('%s/%s', $key, $version); | ||
} | ||
|
||
return implode(' ', $versions); | ||
} | ||
|
||
public function getAll(Context $context): array | ||
{ | ||
return array_filter( | ||
[ | ||
'Shopware' => $this->getShopwareVersion(), | ||
$this->pluginService->getPluginName() => $this->getPluginVersion($context), | ||
'SDK' => $this->getSDKVersion($context), | ||
'PHP' => $this->getPHPVersion(), | ||
] | ||
); | ||
} | ||
|
||
public function getShopwareVersion(): string | ||
{ | ||
return $this->shopwareVersion; | ||
} | ||
|
||
public function getPluginVersion(Context $context): string | ||
{ | ||
return $this->pluginService->getVersion($context); | ||
} | ||
|
||
public function getSDKVersion(Context $context): string | ||
{ | ||
if (empty($this->composerPackages)) { | ||
$path = $this->pluginService->getPath($context); | ||
$fullPath = sprintf( | ||
'%s/%s/%s', | ||
rtrim($this->shopwareRootPath, '/'), | ||
rtrim($path, '/'), | ||
'vendor/composer/installed.php' | ||
); | ||
|
||
if (!file_exists($fullPath)) { | ||
return ''; | ||
} | ||
|
||
try { | ||
$this->composerPackages = include $fullPath; | ||
} | ||
catch (\Throwable $exception) { | ||
return ''; | ||
} | ||
} | ||
|
||
if (!isset($this->composerPackages['versions']['firstred/postnl-api-php']['pretty_version'])) { | ||
return ''; | ||
}; | ||
return $this->composerPackages['versions']['firstred/postnl-api-php']['pretty_version']; | ||
} | ||
|
||
public function getPHPVersion(): string | ||
{ | ||
return phpversion(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PostNL\Shopware6\Service\Shopware; | ||
|
||
use PostNL\Shopware6\PostNLShopware; | ||
use Shopware\Core\Framework\Context; | ||
use Shopware\Core\Framework\Plugin\PluginEntity; | ||
use Shopware\Core\Framework\Plugin\PluginService as ShopwarePluginService; | ||
|
||
class PluginService | ||
{ | ||
protected ShopwarePluginService $pluginService; | ||
protected ?PluginEntity $plugin = null; | ||
|
||
public function __construct(ShopwarePluginService $pluginService) | ||
{ | ||
$this->pluginService = $pluginService; | ||
} | ||
|
||
public function getPlugin(Context $context): PluginEntity | ||
{ | ||
if(!$this->plugin instanceof PluginEntity) { | ||
$this->plugin = $this->pluginService->getPluginByName($this->getPluginName(), $context); | ||
} | ||
|
||
return $this->plugin; | ||
} | ||
|
||
public function getAuthor(Context $context): string | ||
{ | ||
return $this->getPlugin($context)->getAuthor() ?? ''; | ||
} | ||
|
||
public function getPath(Context $context): string | ||
{ | ||
return $this->getPlugin($context)->getPath() ?? ''; | ||
} | ||
|
||
public function getVersion(Context $context): string | ||
{ | ||
return $this->getPlugin($context)->getVersion(); | ||
} | ||
|
||
public function getUpgradeVersion(Context $context): string | ||
{ | ||
return $this->getPlugin($context)->getUpgradeVersion() ?? ''; | ||
} | ||
|
||
public function getPluginName(): string | ||
{ | ||
$className = PostNLShopware::class; | ||
$chunks = explode('\\', $className); | ||
return end($chunks); | ||
} | ||
} |