prestashop / prestashop-accounts-installer
一个实用程序包,用于安装 `ps_accounts` 模块或将数据展示出来以从 psx 配置页面触发手动安装。
v1.0.4
2023-05-04 07:24 UTC
Requires
- php: >=5.6
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.16
- fzaninotto/faker: ^1.9
- phpunit/phpunit: ^5.7
- prestashop/php-dev-tools: 3.*
This package is auto-updated.
Last update: 2024-08-24 08:09:15 UTC
README
一个实用程序包,用于安装 ps_accounts
模块或将数据展示出来以从 psx 配置页面触发手动安装。
此模块还通过其模块服务容器为您提供了访问 ps_accounts
服务的权限,以处理模块的安装状态。
兼容性矩阵
我们部分遵循 Prestashop 兼容性图表
安装
此包可在 Packagist 上找到,您可以通过 Composer 进行安装。
composer require prestashop/prestashop-accounts-installer
在您的 PSx 容器中注册为服务(推荐)
示例
services: <your_module>.ps_accounts_installer: class: 'PrestaShop\PsAccountsInstaller\Installer\Installer' arguments: - '5.0.0' <your_module>.ps_accounts_facade: class: 'PrestaShop\PsAccountsInstaller\Installer\Facade\PsAccounts' arguments: - '@<your_module>.ps_accounts_installer'
在您的服务容器中注册这两个服务的名称必须唯一,以避免与其他模块冲突。
5.0.0
指定的参数是所需的最小 ps_account
模块版本。如果您需要其他版本,应进行修改。
如何使用
安装程序
在您模块的主类 install
方法中。(仅在 PrestaShop 1.7 及以上版本中起作用)
$this->getService('ps_accounts.installer')->install();
展示者
例如,在您主模块的 getContent
方法中。
Media::addJsDef([ 'contextPsAccounts' => $this->getService('ps_accounts.facade') ->getPsAccountsPresenter() ->present($this->name), ]);
此展示者将作为默认的最小展示者,并在 ps_accounts
模块安装时切换到 PsAccountsPresenter 数据。
访问 PsAccounts 服务
安装程序类包括从 PsAccounts 模块获取服务实例的访问器
- getPsAccountsService
- getPsBillingService
上述方法在 ps_accounts
模块未安装或不在所需版本时将抛出异常。
示例
use PrestaShop\PsAccountsInstaller\Installer\Exception\ModuleVersionException; use PrestaShop\PsAccountsInstaller\Installer\Exception\ModuleNotInstalledException; try { $psAccountsService = $this->getService('ps_accounts.facade')->getPsAccountsService(); $shopJwt = $psAccountsService->getOrRefreshToken(); $shopUuid = $psAccountsService->getShopUuid(); $apiUrl = $psAccountsService->getAdminAjaxUrl(); // Your code here } catch (ModuleNotInstalledException $e) { // You handle exception here } catch (ModuleVersionException $e) { // You handle exception here }