-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #184 from bold-commerce/Q1-661
Expose Bold modules installed and their versions through an api endpoint
- Loading branch information
Showing
10 changed files
with
246 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Bold\Checkout\Api\Data\ModuleVersion; | ||
|
||
/** | ||
* Installed module and it's version. | ||
*/ | ||
interface ModuleVersionInterface | ||
{ | ||
/** | ||
* Get module name. | ||
* | ||
* @return string | ||
*/ | ||
public function getName(): string; | ||
|
||
/** | ||
* Get module version. | ||
* | ||
* @return string | ||
*/ | ||
public function getVersion(): string; | ||
} |
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,18 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Bold\Checkout\Api\Data\ModuleVersion; | ||
|
||
/** | ||
* Installed modules and their versions. | ||
*/ | ||
interface ResultInterface | ||
{ | ||
/** | ||
* Installed modules and their versions. | ||
* | ||
* @return \Bold\Checkout\Api\Data\ModuleVersion\ModuleVersionInterface[] | ||
*/ | ||
public function getModules(): array; | ||
} |
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 |
---|---|---|
|
@@ -3,6 +3,9 @@ | |
|
||
namespace Bold\Checkout\Api; | ||
|
||
/** | ||
* @deprecated | ||
*/ | ||
interface GetVersionInterface | ||
{ | ||
/** | ||
|
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,19 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Bold\Checkout\Api; | ||
|
||
/** | ||
* Get all installed modules and their versions. | ||
*/ | ||
interface ModuleVersionInterface | ||
{ | ||
/** | ||
* Get all installed modules and their versions.. | ||
* | ||
* @param string $shopId | ||
* @return \Bold\Checkout\Api\Data\ModuleVersion\ResultInterface | ||
*/ | ||
public function getModuleVersions(string $shopId): Data\ModuleVersion\ResultInterface; | ||
} |
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,49 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Bold\Checkout\Model\Data\ModuleVersion; | ||
|
||
use Bold\Checkout\Api\Data\ModuleVersion\ModuleVersionInterface; | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
class ModuleVersion implements ModuleVersionInterface | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private $name; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $version; | ||
|
||
/** | ||
* @param string $name | ||
* @param string $version | ||
*/ | ||
public function __construct(string $name = '', string $version = '') | ||
{ | ||
$this->name = $name; | ||
$this->version = $version; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getName(): string | ||
{ | ||
return $this->name; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getVersion(): string | ||
{ | ||
return $this->version; | ||
} | ||
} |
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,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Bold\Checkout\Model\Data\ModuleVersion; | ||
|
||
use Bold\Checkout\Api\Data\ModuleVersion\ModuleVersionInterface; | ||
use Bold\Checkout\Api\Data\ModuleVersion\ResultInterface; | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
class Result implements ResultInterface | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
private $modules; | ||
|
||
/** | ||
* @param ModuleVersionInterface[] $modules | ||
*/ | ||
public function __construct(array $modules = []) | ||
{ | ||
$this->modules = $modules; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getModules(): array | ||
{ | ||
return $this->modules; | ||
} | ||
} |
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,87 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Bold\Checkout\Model; | ||
|
||
use Bold\Checkout\Api\Data\ModuleVersion\ModuleVersionInterfaceFactory; | ||
use Bold\Checkout\Api\Data\ModuleVersion\ResultInterface; | ||
use Bold\Checkout\Api\Data\ModuleVersion\ResultInterfaceFactory; | ||
use Bold\Checkout\Api\ModuleVersionInterface; | ||
use Bold\Checkout\Model\ModuleInfo\InstalledModulesProvider; | ||
use Bold\Checkout\Model\ModuleInfo\ModuleComposerNameProvider; | ||
use Bold\Checkout\Model\ModuleInfo\ModuleComposerVersionProvider; | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
class ModuleVersion implements ModuleVersionInterface | ||
{ | ||
/** | ||
* @var InstalledModulesProvider | ||
*/ | ||
private $installedModulesProvider; | ||
|
||
/** | ||
* @var ModuleComposerVersionProvider | ||
*/ | ||
private $composerVersionProvider; | ||
|
||
/** | ||
* @var ModuleComposerNameProvider | ||
*/ | ||
private $composerNameProvider; | ||
|
||
/** | ||
* @var ResultInterfaceFactory | ||
*/ | ||
private $resultFactory; | ||
|
||
/** | ||
* @var ModuleVersionInterfaceFactory | ||
*/ | ||
private $moduleVersionFactory; | ||
|
||
/** | ||
* @param InstalledModulesProvider $installedModulesProvider | ||
* @param ModuleComposerVersionProvider $composerVersionProvider | ||
* @param ModuleComposerNameProvider $composerNameProvider | ||
* @param ResultInterfaceFactory $resultFactory | ||
* @param ModuleVersionInterfaceFactory $moduleVersionFactory | ||
*/ | ||
public function __construct( | ||
InstalledModulesProvider $installedModulesProvider, | ||
ModuleComposerVersionProvider $composerVersionProvider, | ||
ModuleComposerNameProvider $composerNameProvider, | ||
ResultInterfaceFactory $resultFactory, | ||
ModuleVersionInterfaceFactory $moduleVersionFactory | ||
) { | ||
$this->installedModulesProvider = $installedModulesProvider; | ||
$this->composerVersionProvider = $composerVersionProvider; | ||
$this->composerNameProvider = $composerNameProvider; | ||
$this->resultFactory = $resultFactory; | ||
$this->moduleVersionFactory = $moduleVersionFactory; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getModuleVersions(string $shopId): ResultInterface | ||
{ | ||
return $this->resultFactory->create( | ||
[ | ||
'modules' => array_map( | ||
function (string $moduleName) { | ||
return $this->moduleVersionFactory->create( | ||
[ | ||
'name' => $this->composerNameProvider->getName($moduleName), | ||
'version' => $this->composerVersionProvider->getVersion($moduleName) | ||
] | ||
); | ||
}, | ||
$this->installedModulesProvider->getModuleList() | ||
), | ||
] | ||
); | ||
} | ||
} |
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