-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add url for install psbo && update module
- Loading branch information
Showing
7 changed files
with
173 additions
and
4 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,6 @@ | ||
services: | ||
ps_eventbus.helper.module: | ||
class: 'PrestaShop\Module\Ps_eventbus\Helper\ModuleHelper' | ||
arguments: | ||
- "@ps_eventbus" | ||
public: true |
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,36 @@ | ||
<?php | ||
|
||
namespace PrestaShop\Module\Ps_eventbus\Helper; | ||
|
||
use PrestaShopBundle\Service\Routing\Router; | ||
use Ps_eventbus; | ||
|
||
class ModuleHelper | ||
{ | ||
/** @var Ps_eventbus */ | ||
private $module; | ||
|
||
public function __construct(Ps_eventbus $module) | ||
{ | ||
$this->module = $module; | ||
} | ||
|
||
/** | ||
* returns the update link of the module if it is not enabled. If enabled, returns an empty string | ||
* | ||
* @param string $moduleName | ||
* | ||
* @return string | ||
*/ | ||
public function getUpdateLink(string $moduleName) | ||
{ | ||
/** @var Router $router * */ | ||
$router = $this->module->getService('router'); | ||
|
||
return substr(\Tools::getShopDomainSsl(true) . __PS_BASE_URI__, 0, -1) . | ||
$router->generate('admin_module_manage_action', [ | ||
'action' => 'upgrade', | ||
'module_name' => $moduleName, | ||
]); | ||
} | ||
} |
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 | ||
|
||
namespace PrestaShop\Module\Ps_eventbus\Module; | ||
|
||
use PrestaShop\PrestaShop\Core\Addon\Module\ModuleManagerBuilder; | ||
use Prestashop\ModuleLibMboInstaller\Presenter as MBOPresenter; | ||
use Prestashop\ModuleLibMboInstaller\Installer as MBOInstaller; | ||
use Ps_eventbus; | ||
|
||
class Upgrade | ||
{ | ||
/** | ||
* @var Ps_eventbus | ||
*/ | ||
private $module; | ||
|
||
/** | ||
* Install constructor. | ||
* | ||
* @param Ps_eventbus $module | ||
* | ||
* @return void | ||
*/ | ||
public function __construct(Ps_eventbus $module) | ||
{ | ||
$this->module = $module; | ||
} | ||
|
||
/** | ||
* Upgrade ps_eventbus module | ||
* | ||
* @return bool | ||
*/ | ||
public function upgradePsEventbus() | ||
{ | ||
$mboStatus = (new MBOPresenter)->present(); | ||
|
||
if ($mboStatus['isInstalled'] == false && $mboStatus['isEnabled']) { | ||
try { | ||
$mboInstaller = new MBOInstaller(_PS_VERSION_); | ||
$mboInstaller->installModule(); | ||
} catch (\Exception $e) { | ||
throw new \Exception('Error while installing MBO module'); | ||
} | ||
} | ||
|
||
if (true === \Module::needUpgrade($this->module)) { | ||
/** @var ModuleManagerBuilder $moduleManagerBuilder */ | ||
$moduleManagerBuilder = ModuleManagerBuilder::getInstance(); | ||
$moduleManager = $moduleManagerBuilder->build(); | ||
|
||
return $moduleManager->upgrade((string) $this->module->name); | ||
} | ||
|
||
return true; | ||
} | ||
} |
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