Initial commit

This commit is contained in:
2020-10-07 10:37:15 +02:00
commit ce5f440392
28157 changed files with 4429172 additions and 0 deletions

47
modules/ps_mbo/LICENSE.md Normal file
View File

@@ -0,0 +1,47 @@
Academic Free License ("AFL") v. 3.0
This Academic Free License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work:
Licensed under the Academic Free License version 3.0
1) Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following:
a) to reproduce the Original Work in copies, either alone or as part of a collective work;
b) to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work;
c) to distribute or communicate copies of the Original Work and Derivative Works to the public, under any license of your choice that does not contradict the terms and conditions, including Licensor's reserved rights and remedies, in this Academic Free License;
d) to perform the Original Work publicly; and
e) to display the Original Work publicly.
2) Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works.
3) Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work.
4) Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license.
5) External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c).
6) Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work.
7) Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer.
8) Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation.
9) Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including "fair use" or "fair dealing"). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c).
10) Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware.
11) Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License.
12) Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License.
13) Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable.
14) Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
15) Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You.
16) Modification of This License. This License is Copyright © 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Academic Free License" or "AFL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under <insert your license name here>" or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process.

33
modules/ps_mbo/Makefile Normal file
View File

@@ -0,0 +1,33 @@
help:
@egrep "^#" Makefile
# target: docker-build|db - Setup/Build PHP & (node)JS dependencies
db: docker-build
docker-build: build-back
build-back:
docker-compose run --rm php sh -c "composer install"
build-back-prod:
docker-compose run --rm php sh -c "composer install --no-dev -o"
build-zip:
cp -Ra $(PWD) /tmp/ps_mbo
rm -rf /tmp/ps_mbo/.env.test
rm -rf /tmp/ps_mbo/.php_cs.*
rm -rf /tmp/ps_mbo/composer.*
rm -rf /tmp/ps_mbo/.gitignore
rm -rf /tmp/ps_mbo/deploy.sh
rm -rf /tmp/ps_mbo/.editorconfig
rm -rf /tmp/ps_mbo/.git
rm -rf /tmp/ps_mbo/.github
rm -rf /tmp/ps_mbo/_dev
rm -rf /tmp/ps_mbo/tests
rm -rf /tmp/ps_mbo/docker-compose.yml
rm -rf /tmp/ps_mbo/Makefile
mv -v /tmp/ps_mbo $(PWD)/ps_mbo
zip -r ps_mbo.zip ps_mbo
rm -rf $(PWD)/ps_mbo
# target: build-zip-prod - Launch prod zip generation of the module (will not work on windows)
build-zip-prod: build-back-prod build-zip

31
modules/ps_mbo/README.md Normal file
View File

@@ -0,0 +1,31 @@
# MBO
PrestaShop Marketplace in your Back Office
## About
Discover the best PrestaShop modules to optimize your online store.
## Reporting issues
You can report issues with this module in the main PrestaShop repository. [Click here to report an issue][report-issue].
## Multistore compatibility
This module is compatible with the multistore :heavy_check_mark:
- It can be activated on one store and deactivated on another
## Contributing
PrestaShop modules are open source extensions to the [PrestaShop e-commerce platform][prestashop]. Everyone is welcome and even encouraged to contribute with their own improvements!
Just make sure to follow our [contribution guidelines][contribution-guidelines].
## License
This module is released under the [Academic Free License 3.0][AFL-3.0]
[report-issue]: https://github.com/PrestaShop/PrestaShop/issues/new/choose
[prestashop]: https://www.prestashop.com/
[contribution-guidelines]: https://devdocs.prestashop.com/1.7/contribute/contribution-guidelines/project-modules/
[AFL-3.0]: https://opensource.org/licenses/AFL-3.0

View File

@@ -0,0 +1,35 @@
{
"name": "prestashop/ps_mbo",
"description": "PrestaShop module ps_mbo",
"homepage": "https://github.com/PrestaShop/ps_mbo",
"license": "AFL-3.0",
"type": "prestashop-module",
"authors": [
{
"name": "PrestaShop SA",
"email": "contact@prestashop.com"
}
],
"config": {
"platform": {
"php": "5.6.0"
},
"preferred-install": "dist",
"optimize-autoloader": true,
"prepend-autoloader": false
},
"require": {
"php": ">=5.6.0",
"ext-simplexml": "*",
"prestashop/circuit-breaker": "^3.0.0"
},
"require-dev": {
"prestashop/php-dev-tools": "^2.2"
},
"autoload": {
"psr-4": {
"PrestaShop\\Module\\Mbo\\": "src/"
},
"classmap": ["ps_mbo.php"]
}
}

1611
modules/ps_mbo/composer.lock generated Normal file

File diff suppressed because it is too large Load Diff

12
modules/ps_mbo/config.xml Normal file
View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>ps_mbo</name>
<displayName><![CDATA[PrestaShop Marketplace in your Back Office]]></displayName>
<version><![CDATA[2.0.1]]></version>
<description><![CDATA[Discover the best PrestaShop modules to optimize your online store.]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[administration]]></tab>
<is_configurable>0</is_configurable>
<need_instance>0</need_instance>
<limited_countries></limited_countries>
</module>

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,31 @@
admin_mbo_catalog_module:
path: /addons/modules/catalog
methods: [GET]
defaults:
_controller: mbo.controller.modules.catalog:indexAction
_legacy_controller: AdminPsMboModule
_legacy_link: AdminPsMboModule
admin_mbo_catalog_module_selection:
path: /addons/modules/catalog/selection
methods: [GET]
defaults:
_controller: mbo.controller.modules.selection:indexAction
_legacy_controller: AdminPsMboAddons
_legacy_link: AdminPsMboAddons
admin_mbo_recommended_modules:
path: /addons/modules/recommended
methods: [GET]
defaults:
_controller: mbo.controller.modules.recommended:indexAction
_legacy_controller: AdminPsMboRecommended
_legacy_link: AdminPsMboRecommended
admin_mbo_catalog_theme:
path: /addons/themes/catalog
methods: [GET]
defaults:
_controller: mbo.controller.themes.catalog:indexAction
_legacy_controller: AdminPsMboTheme
_legacy_link: AdminPsMboTheme

View File

@@ -0,0 +1,69 @@
services:
_defaults:
public: true
mbo.externalcontent.provider:
class: 'PrestaShop\Module\Mbo\ExternalContentProvider\ExternalContentProvider'
mbo.adapter.module_collection_data_provider:
class: 'PrestaShop\Module\Mbo\ModuleCollectionDataProvider'
arguments:
- '@prestashop.core.admin.data_provider.module_interface'
- '@prestashop.core.admin.module.repository'
- '@prestashop.adapter.presenter.module'
- '@prestashop.core.admin.tab.repository'
- '@prestashop.adapter.legacy.context'
mbo.tab.collection.factory:
class: 'PrestaShop\Module\Mbo\Tab\TabCollectionFactory'
arguments:
- '@mbo.adapter.module_collection_data_provider'
mbo.tab.collection.provider:
class: 'PrestaShop\Module\Mbo\Tab\TabCollectionProvider'
arguments:
- '@prestashop.adapter.legacy.context'
- '@mbo.externalcontent.provider'
- '@mbo.tab.collection.factory'
- '@doctrine.cache.provider'
mbo.recommendedlinks.provider:
class: 'PrestaShop\Module\Mbo\RecommendedLink\RecommendedLinkProvider'
arguments:
- '@prestashop.adapter.legacy.context'
- '@serializer'
mbo.recommendedmodules.presenter:
class: 'PrestaShop\Module\Mbo\RecommendedModule\RecommendedModulePresenter'
mbo.addons_selection_link_provider:
class: 'PrestaShop\Module\Mbo\AddonsSelectionLinkProvider'
arguments:
- '@prestashop.core.foundation.version'
- '@prestashop.adapter.legacy.context'
- '@prestashop.adapter.legacy.configuration'
- '@request_stack'
mbo.controller.modules.catalog:
class: 'PrestaShop\Module\Mbo\Controller\Admin\ModuleCatalogController'
mbo.controller.modules.selection:
class: 'PrestaShop\Module\Mbo\Controller\Admin\ModuleSelectionController'
arguments:
- '@request_stack'
- '@mbo.externalcontent.provider'
- '@mbo.addons_selection_link_provider'
mbo.controller.modules.recommended:
class: 'PrestaShop\Module\Mbo\Controller\Admin\ModuleRecommendedController'
arguments:
- '@request_stack'
- '@mbo.tab.collection.provider'
- '@mbo.recommendedmodules.presenter'
mbo.controller.themes.catalog:
class: 'PrestaShop\Module\Mbo\Controller\Admin\ThemeCatalogController'
arguments:
- '@request_stack'
- '@mbo.externalcontent.provider'
- '@mbo.addons_selection_link_provider'

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>ps_mbo</name>
<displayName><![CDATA[PrestaShop Marketplace in your Back Office]]></displayName>
<version><![CDATA[2.0.1]]></version>
<description><![CDATA[Discover the best PrestaShop modules to optimize your online store.]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[administration]]></tab>
<is_configurable>0</is_configurable>
<need_instance>0</need_instance>
<limited_countries></limited_countries>
</module>

28
modules/ps_mbo/index.php Normal file
View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

BIN
modules/ps_mbo/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

411
modules/ps_mbo/ps_mbo.php Normal file
View File

@@ -0,0 +1,411 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
if (!defined('_PS_VERSION_')) {
exit;
}
$autoloadPath = __DIR__ . '/vendor/autoload.php';
if (file_exists($autoloadPath)) {
require_once $autoloadPath;
}
use PrestaShop\Module\Mbo\Tab\TabCollectionProvider;
use PrestaShop\PrestaShop\Adapter\SymfonyContainer;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
class ps_mbo extends Module
{
const TABS_WITH_RECOMMENDED_MODULES_BUTTON = [
'AdminProducts',
'AdminCategories',
'AdminTracking',
'AdminAttributesGroups',
'AdminFeatures',
'AdminManufacturers',
'AdminSuppliers',
'AdminTags',
'AdminOrders',
'AdminInvoices',
'AdminReturn',
'AdminDeliverySlip',
'AdminSlip',
'AdminStatuses',
'AdminOrderMessage',
'AdminCustomers',
'AdminAddresses',
'AdminGroups',
'AdminCarts',
'AdminCustomerThreads',
'AdminContacts',
'AdminCartRules',
'AdminSpecificPriceRule',
'AdminShipping',
'AdminLocalization',
'AdminZones',
'AdminCountries',
'AdminCurrencies',
'AdminTaxes',
'AdminTaxRulesGroup',
'AdminTranslations',
'AdminPreferences',
'AdminOrderPreferences',
'AdminPPreferences',
'AdminCustomerPreferences',
'AdminThemes',
'AdminMeta',
'AdminCmsContent',
'AdminImages',
'AdminSearchConf',
'AdminGeolocation',
'AdminInformation',
'AdminPerformance',
'AdminEmails',
'AdminImport',
'AdminBackup',
'AdminRequestSql',
'AdminLogs',
'AdminAdminPreferences',
'AdminStats',
'AdminSearchEngines',
'AdminReferrers',
];
const TABS_WITH_RECOMMENDED_MODULES_AFTER_CONTENT = [
'AdminMarketing',
'AdminPayment',
'AdminCarriers',
];
const ADMIN_CONTROLLERS = [
'AdminPsMboModule' => [
'name' => 'Module catalog',
'visible' => true,
'class_name' => 'AdminPsMboModule',
'parent_class_name' => 'AdminParentModulesCatalog',
'core_reference' => 'AdminModulesCatalog',
],
'AdminPsMboAddons' => [
'name' => 'Module selection',
'visible' => true,
'class_name' => 'AdminPsMboAddons',
'parent_class_name' => 'AdminParentModulesCatalog',
'core_reference' => 'AdminAddonsCatalog',
],
'AdminPsMboRecommended' => [
'name' => 'Module recommended',
'visible' => true,
'class_name' => 'AdminPsMboRecommended',
],
'AdminPsMboTheme' => [
'name' => 'Theme catalog',
'visible' => true,
'class_name' => 'AdminPsMboTheme',
'parent_class_name' => 'AdminParentThemes',
'core_reference' => 'AdminThemesCatalog',
],
];
const HOOKS = [
'actionAdminControllerSetMedia',
'displayDashboardTop',
];
/**
* @var ContainerInterface
*/
protected $container;
/**
* Constructor.
*/
public function __construct()
{
$this->name = 'ps_mbo';
$this->version = '2.0.1';
$this->author = 'PrestaShop';
$this->tab = 'administration';
$this->module_key = '6cad5414354fbef755c7df4ef1ab74eb';
$this->need_instance = 0;
$this->ps_versions_compliancy = [
'min' => '1.7.5.0',
'max' => _PS_VERSION_,
];
parent::__construct();
$this->displayName = $this->l('PrestaShop Marketplace in your Back Office');
$this->description = $this->l('Discover the best PrestaShop modules to optimize your online store.');
}
/**
* Install Module.
*
* @return bool
*/
public function install()
{
return parent::install()
&& $this->registerHook(static::HOOKS)
&& $this->installTabs();
}
/**
* Install all Tabs.
*
* @return bool
*/
public function installTabs()
{
foreach (static::ADMIN_CONTROLLERS as $adminTab) {
if (false === $this->installTab($adminTab)) {
return false;
}
}
return true;
}
/**
* Install Tab.
* Used in upgrade script.
*
* @param array $tabData
*
* @return bool
*/
public function installTab(array $tabData)
{
$position = 0;
$tabNameByLangId = array_fill_keys(
Language::getIDs(false),
$tabData['name']
);
if (isset($tabData['core_reference'])) {
$tabCoreId = Tab::getIdFromClassName($tabData['core_reference']);
if ($tabCoreId !== false) {
$tabCore = new Tab($tabCoreId);
$tabNameByLangId = $tabCore->name;
$position = $tabCore->position;
$tabCore->active = false;
$tabCore->save();
}
}
$tab = new Tab();
$tab->module = $this->name;
$tab->class_name = $tabData['class_name'];
$tab->position = (int) $position;
$tab->id_parent = empty($tabData['parent_class_name']) ? -1 : Tab::getIdFromClassName($tabData['parent_class_name']);
$tab->name = $tabNameByLangId;
if (false === (bool) $tab->add()) {
return false;
}
if (Validate::isLoadedObject($tab)) {
// Updating the id_parent will override the position, that's why we save 2 times
$tab->position = (int) $position;
$tab->save();
}
return true;
}
/**
* Uninstall Module.
*
* @return bool
*/
public function uninstall()
{
return parent::uninstall()
&& $this->uninstallTabs();
}
/**
* Uninstall all Tabs.
*
* @return bool
*/
public function uninstallTabs()
{
foreach (static::ADMIN_CONTROLLERS as $adminTab) {
if (false === $this->uninstallTab($adminTab)) {
return false;
}
}
return true;
}
/**
* Uninstall Tab.
* Can be used in upgrade script.
*
* @param array $tabData
*
* @return bool
*/
public function uninstallTab(array $tabData)
{
$tabId = Tab::getIdFromClassName($tabData['class_name']);
$tab = new Tab($tabId);
if (false === Validate::isLoadedObject($tab)) {
return false;
}
if (false === (bool) $tab->delete()) {
return false;
}
if (isset($tabData['core_reference'])) {
$tabCoreId = Tab::getIdFromClassName($tabData['core_reference']);
$tabCore = new Tab($tabCoreId);
if (Validate::isLoadedObject($tabCore)) {
$tabCore->active = true;
}
if (false === (bool) $tabCore->save()) {
return false;
}
}
return true;
}
/**
* Hook actionAdminControllerSetMedia.
*/
public function hookActionAdminControllerSetMedia()
{
// has to be loaded in header to prevent flash of content
$this->context->controller->addJs($this->getPathUri() . 'views/js/recommended-modules.js?v=' . $this->version);
if ($this->shouldAttachRecommendedModulesButton()
|| $this->shouldAttachRecommendedModulesAfterContent()
) {
$this->context->controller->addCSS($this->getPathUri() . 'views/css/recommended-modules.css');
$this->context->controller->addJs(
rtrim(__PS_BASE_URI__, '/')
. str_ireplace(
_PS_CORE_DIR_,
'',
_PS_BO_ALL_THEMES_DIR_
)
. 'default/js/bundle/module/module_card.js?v='
. _PS_VERSION_
);
}
}
/**
* Hook displayDashboardTop.
* Includes content just below the toolbar.
*
* @return string
*/
public function hookDisplayDashboardTop()
{
/** @var UrlGeneratorInterface $router */
$router = $this->get('router');
try {
$recommendedModulesUrl = $router->generate(
'admin_mbo_recommended_modules',
[
'tabClassName' => Tools::getValue('controller'),
]
);
} catch (Exception $exception) {
// Avoid fatal errors on ServiceNotFoundException
return '';
}
$this->smarty->assign([
'shouldAttachRecommendedModulesAfterContent' => $this->shouldAttachRecommendedModulesAfterContent(),
'shouldAttachRecommendedModulesButton' => $this->shouldAttachRecommendedModulesButton(),
'shouldUseLegacyTheme' => $this->isAdminLegacyContext(),
'recommendedModulesTitleTranslated' => $this->trans('Recommended Modules and Services'),
'recommendedModulesCloseTranslated' => $this->trans('Close', [], 'Admin.Actions'),
'recommendedModulesUrl' => $recommendedModulesUrl,
]);
return $this->fetch('module:ps_mbo/views/templates/hook/recommended-modules.tpl');
}
/**
* Indicates if the recommended modules should be attached after content in this page
*
* @return bool
*/
private function shouldAttachRecommendedModulesAfterContent()
{
// AdminLogin should not call TabCollectionProvider
if (Validate::isLoadedObject($this->context->employee)) {
/** @var TabCollectionProvider $tabCollectionProvider */
$tabCollectionProvider = $this->get('mbo.tab.collection.provider');
if ($tabCollectionProvider->isTabCollectionCached()) {
return $tabCollectionProvider->getTabCollection()->getTab(Tools::getValue('controller'))->shouldDisplayAfterContent()
|| 'AdminCarriers' === Tools::getValue('controller');
}
}
return in_array(Tools::getValue('controller'), static::TABS_WITH_RECOMMENDED_MODULES_AFTER_CONTENT, true);
}
/**
* Indicates if the recommended modules button should be attached in this page
*
* @return bool
*/
private function shouldAttachRecommendedModulesButton()
{
// AdminLogin should not call TabCollectionProvider
if (Validate::isLoadedObject($this->context->employee)) {
/** @var TabCollectionProvider $tabCollectionProvider */
$tabCollectionProvider = $this->get('mbo.tab.collection.provider');
if ($tabCollectionProvider->isTabCollectionCached()) {
return $tabCollectionProvider->getTabCollection()->getTab(Tools::getValue('controller'))->shouldDisplayButton()
&& 'AdminCarriers' !== Tools::getValue('controller');
}
}
return in_array(Tools::getValue('controller'), static::TABS_WITH_RECOMMENDED_MODULES_BUTTON, true);
}
/**
* Override of native function to always retrieve Symfony container instead of legacy admin container on legacy context.
*
* {@inheritdoc}
*/
public function get($serviceName)
{
if (null === $this->container) {
$this->container = SymfonyContainer::getInstance();
}
return $this->container->get($serviceName);
}
}

View File

@@ -0,0 +1,93 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
namespace PrestaShop\Module\Mbo;
use PrestaShop\PrestaShop\Adapter\Configuration;
use PrestaShop\PrestaShop\Adapter\LegacyContext;
use PrestaShop\PrestaShop\Core\Foundation\Version;
use Symfony\Component\HttpFoundation\RequestStack;
/**
* Responsible of provide Addons url with Context params for Module Selection and Theme Catalog pages
*/
class AddonsSelectionLinkProvider
{
/**
* @var Version
*/
private $version;
/**
* @var LegacyContext
*/
private $context;
/**
* @var Configuration
*/
private $configuration;
/**
* @var RequestStack
*/
private $requestStack;
/**
* @param Version $version
* @param LegacyContext $context
* @param Configuration $configuration
* @param RequestStack $requestStack
*/
public function __construct(
Version $version,
LegacyContext $context,
Configuration $configuration,
RequestStack $requestStack
) {
$this->version = $version;
$this->context = $context;
$this->configuration = $configuration;
$this->requestStack = $requestStack;
}
/**
* We cannot use http_build_query() here due to a bug on Addons
*
* @see https://github.com/PrestaShop/PrestaShop/pull/9255/files#r200498010
*
* @return string
*/
public function getLinkUrl()
{
$link = 'https://addons.prestashop.com/iframe/search-1.7.php?psVersion=' . $this->version->getVersion()
. '&isoLang=' . $this->context->getContext()->language->iso_code
. '&isoCurrency=' . $this->context->getContext()->currency->iso_code
. '&isoCountry=' . $this->context->getContext()->country->iso_code
. '&activity=' . $this->configuration->getInt('PS_SHOP_ACTIVITY')
. '&parentUrl=' . $this->requestStack->getCurrentRequest()->getSchemeAndHttpHost();
if ('AdminPsMboTheme' === $this->requestStack->getCurrentRequest()->attributes->get('_legacy_controller')) {
$link .= '&onlyThemes=1';
}
return $link;
}
}

View File

@@ -0,0 +1,60 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
namespace PrestaShop\Module\Mbo\Controller\Admin;
use PrestaShopBundle\Controller\Admin\Improve\Modules\ModuleAbstractController;
use PrestaShopBundle\Security\Annotation\AdminSecurity;
use Symfony\Component\HttpFoundation\Response;
/**
* Responsible of "Improve > Modules > Modules Catalog" page display.
*/
class ModuleCatalogController extends ModuleAbstractController
{
/**
* Module Catalog page
*
* @AdminSecurity("is_granted(['read', 'create', 'update', 'delete'], 'ADMINMODULESSF_')")
*
* @return Response
*/
public function indexAction()
{
return $this->render(
'@PrestaShop/Admin/Module/catalog.html.twig',
[
'layoutHeaderToolbarBtn' => $this->getToolbarButtons(),
'layoutTitle' => $this->trans('Modules catalog', 'Admin.Navigation.Menu'),
'requireAddonsSearch' => true,
'requireBulkActions' => false,
'showContentHeader' => true,
'enableSidebar' => true,
'help_link' => $this->generateSidebarLink('AdminModules'),
'requireFilterStatus' => false,
'level' => $this->authorizationLevel(self::CONTROLLER_NAME),
'errorMessage' => $this->trans(
'You do not have permission to add this.',
'Admin.Notifications.Error'
),
]
);
}
}

View File

@@ -0,0 +1,95 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
namespace PrestaShop\Module\Mbo\Controller\Admin;
use PrestaShop\Module\Mbo\RecommendedModule\RecommendedModulePresenterInterface;
use PrestaShop\Module\Mbo\Tab\TabCollectionProviderInterface;
use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException;
/**
* Responsible of render json data for ajax display of Recommended Modules.
*/
class ModuleRecommendedController extends FrameworkBundleAdminController
{
/**
* @var RequestStack
*/
private $requestStack;
/**
* @var TabCollectionProviderInterface
*/
private $tabCollectionProvider;
/**
* @var RecommendedModulePresenterInterface
*/
private $recommendedModulePresenter;
/**
* @param RequestStack $requestStack
* @param TabCollectionProviderInterface $tabCollectionProvider
* @param RecommendedModulePresenterInterface $recommendedModulePresenter
*/
public function __construct(
RequestStack $requestStack,
TabCollectionProviderInterface $tabCollectionProvider,
RecommendedModulePresenterInterface $recommendedModulePresenter
) {
parent::__construct();
$this->requestStack = $requestStack;
$this->tabCollectionProvider = $tabCollectionProvider;
$this->recommendedModulePresenter = $recommendedModulePresenter;
}
/**
* @return JsonResponse
*/
public function indexAction()
{
$response = new JsonResponse();
try {
$tabCollection = $this->tabCollectionProvider->getTabCollection();
$tabClassName = $this->requestStack->getCurrentRequest()->get('tabClassName');
$tab = $tabCollection->getTab($tabClassName);
$response->setData([
'content' => $this->renderView(
'@Modules/ps_mbo/views/templates/admin/controllers/module_catalog/recommended-modules.html.twig',
[
'recommendedModulesInstalled' => $this->recommendedModulePresenter->presentCollection($tab->getRecommendedModulesInstalled()),
'recommendedModulesNotInstalled' => $this->recommendedModulePresenter->presentCollection($tab->getRecommendedModulesNotInstalled()),
]
),
]);
} catch (ServiceUnavailableHttpException $exception) {
$response->setData([
'content' => $this->renderView('@Modules/ps_mbo/views/templates/admin/error.html.twig'),
]);
$response->setStatusCode($exception->getStatusCode());
$response->headers->add($exception->getHeaders());
}
return $response;
}
}

View File

@@ -0,0 +1,100 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
namespace PrestaShop\Module\Mbo\Controller\Admin;
use PrestaShop\Module\Mbo\AddonsSelectionLinkProvider;
use PrestaShop\Module\Mbo\ExternalContentProvider\ExternalContentProviderInterface;
use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController;
use PrestaShopBundle\Security\Annotation\AdminSecurity;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException;
/**
* Responsible of "Improve > Modules > Modules Catalog > Modules Selection" page display.
*/
class ModuleSelectionController extends FrameworkBundleAdminController
{
/**
* @var RequestStack
*/
private $requestStack;
/**
* @var ExternalContentProviderInterface
*/
private $externalContentProvider;
/**
* @var AddonsSelectionLinkProvider
*/
private $addonsSelectionLinkProvider;
/**
* @param RequestStack $requestStack
* @param ExternalContentProviderInterface $externalContentCollectionProvider
* @param AddonsSelectionLinkProvider $addonsSelectionLinkProvider
*/
public function __construct(
RequestStack $requestStack,
ExternalContentProviderInterface $externalContentCollectionProvider,
AddonsSelectionLinkProvider $addonsSelectionLinkProvider
) {
parent::__construct();
$this->requestStack = $requestStack;
$this->externalContentProvider = $externalContentCollectionProvider;
$this->addonsSelectionLinkProvider = $addonsSelectionLinkProvider;
}
/**
* @AdminSecurity("is_granted('read', request.get('_legacy_controller'))")
*
* @return Response
*/
public function indexAction()
{
$response = new Response();
try {
$response->setContent($this->renderView(
'@Modules/ps_mbo/views/templates/admin/controllers/module_catalog/addons_store.html.twig',
[
'pageContent' => $this->externalContentProvider->getContent($this->addonsSelectionLinkProvider->getLinkUrl()),
'layoutHeaderToolbarBtn' => [],
'layoutTitle' => $this->trans('Module selection', 'Admin.Navigation.Menu'),
'requireAddonsSearch' => true,
'requireBulkActions' => false,
'showContentHeader' => true,
'enableSidebar' => true,
'help_link' => $this->generateSidebarLink($this->requestStack->getCurrentRequest()->get('_legacy_controller')),
'requireFilterStatus' => false,
'level' => $this->authorizationLevel($this->requestStack->getCurrentRequest()->get('_legacy_controller')),
]
));
} catch (ServiceUnavailableHttpException $exception) {
$response->setContent($this->renderView('@Modules/ps_mbo/views/templates/admin/error.html.twig'));
$response->setStatusCode($exception->getStatusCode());
$response->headers->add($exception->getHeaders());
}
return $response;
}
}

View File

@@ -0,0 +1,100 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
namespace PrestaShop\Module\Mbo\Controller\Admin;
use PrestaShop\Module\Mbo\AddonsSelectionLinkProvider;
use PrestaShop\Module\Mbo\ExternalContentProvider\ExternalContentProviderInterface;
use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController;
use PrestaShopBundle\Security\Annotation\AdminSecurity;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException;
/**
* Responsible of "Improve > Design > Themes Catalog" page display.
*/
class ThemeCatalogController extends FrameworkBundleAdminController
{
/**
* @var RequestStack
*/
private $requestStack;
/**
* @var ExternalContentProviderInterface
*/
private $externalContentProvider;
/**
* @var AddonsSelectionLinkProvider
*/
private $addonsSelectionLinkProvider;
/**
* @param RequestStack $requestStack
* @param ExternalContentProviderInterface $externalContentCollectionProvider
* @param AddonsSelectionLinkProvider $addonsSelectionLinkProvider
*/
public function __construct(
RequestStack $requestStack,
ExternalContentProviderInterface $externalContentCollectionProvider,
AddonsSelectionLinkProvider $addonsSelectionLinkProvider
) {
parent::__construct();
$this->requestStack = $requestStack;
$this->externalContentProvider = $externalContentCollectionProvider;
$this->addonsSelectionLinkProvider = $addonsSelectionLinkProvider;
}
/**
* @AdminSecurity("is_granted('read', request.get('_legacy_controller'))")
*
* @return Response
*/
public function indexAction()
{
$response = new Response();
try {
$response->setContent($this->renderView(
'@Modules/ps_mbo/views/templates/admin/controllers/theme_catalog/addons_store.html.twig',
[
'pageContent' => $this->externalContentProvider->getContent($this->addonsSelectionLinkProvider->getLinkUrl()),
'layoutHeaderToolbarBtn' => [],
'layoutTitle' => $this->trans('Themes Catalog', 'Admin.Navigation.Menu'),
'requireAddonsSearch' => true,
'requireBulkActions' => false,
'showContentHeader' => true,
'enableSidebar' => true,
'help_link' => $this->generateSidebarLink($this->requestStack->getCurrentRequest()->get('_legacy_controller')),
'requireFilterStatus' => false,
'level' => $this->authorizationLevel($this->requestStack->getCurrentRequest()->get('_legacy_controller')),
]
));
} catch (ServiceUnavailableHttpException $exception) {
$response->setContent($this->renderView('@Modules/ps_mbo/views/templates/admin/error.html.twig'));
$response->setStatusCode($exception->getStatusCode());
$response->headers->add($exception->getHeaders());
}
return $response;
}
}

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,106 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
namespace PrestaShop\Module\Mbo\ExternalContentProvider;
use Closure;
use PrestaShop\CircuitBreaker\FactorySettings;
use PrestaShop\CircuitBreaker\SimpleCircuitBreakerFactory;
use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException;
use Symfony\Component\OptionsResolver\OptionsResolver;
class ExternalContentProvider implements ExternalContentProviderInterface
{
const ALLOWED_FAILURES = 2;
const TIMEOUT_SECONDS = 0.6;
const THRESHOLD_SECONDS = 3600; // Retry in 1 hour
/**
* @var SimpleCircuitBreakerFactory
*/
private $circuitBreakerFactory;
/**
* @var OptionsResolver
*/
private $optionsResolver;
/**
* Constructor.
*/
public function __construct()
{
$this->circuitBreakerFactory = new SimpleCircuitBreakerFactory();
$this->optionsResolver = new OptionsResolver();
$this->configureOptions();
}
/**
* {@inheritdoc}
*
* @throws ServiceUnavailableHttpException
*/
public function getContent($url, array $options = [])
{
$settings = $this->optionsResolver->resolve($options);
$apiSettings = new FactorySettings(
$settings['failures'],
$settings['timeout'],
$settings['threshold']
);
$circuitBreaker = $this->circuitBreakerFactory->create($apiSettings);
return $circuitBreaker->call(
$url,
$settings['client_options'],
$this->circuitBreakerFallback()
);
}
private function configureOptions()
{
$this->optionsResolver->setDefaults([
'failures' => self::ALLOWED_FAILURES,
'timeout' => self::TIMEOUT_SECONDS,
'threshold' => self::THRESHOLD_SECONDS,
'client_options' => [],
]);
$this->optionsResolver->setAllowedTypes('failures', 'numeric');
$this->optionsResolver->setAllowedTypes('timeout', 'numeric');
$this->optionsResolver->setAllowedTypes('threshold', 'numeric');
$this->optionsResolver->setAllowedTypes('client_options', 'array');
}
/**
* Called by CircuitBreaker if the service is unavailable
*
* @return Closure
*/
private function circuitBreakerFallback()
{
return function () {
throw new ServiceUnavailableHttpException(self::THRESHOLD_SECONDS);
};
}
}

View File

@@ -0,0 +1,32 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
namespace PrestaShop\Module\Mbo\ExternalContentProvider;
interface ExternalContentProviderInterface
{
/**
* @param string $url
* @param array $options
*
* @return string
*/
public function getContent($url, array $options = []);
}

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,132 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
namespace PrestaShop\Module\Mbo;
use Module;
use PrestaShop\PrestaShop\Adapter\LegacyContext;
use PrestaShop\PrestaShop\Adapter\Module\AdminModuleDataProvider;
use PrestaShop\PrestaShop\Adapter\Presenter\PresenterInterface;
use PrestaShop\PrestaShop\Core\Addon\AddonsCollection;
use PrestaShop\PrestaShop\Core\Addon\Module\ModuleRepository;
use PrestaShop\PrestaShop\Core\Addon\Module\ModuleRepositoryInterface;
use PrestaShopBundle\Entity\Repository\TabRepository;
use Profile;
class ModuleCollectionDataProvider
{
/**
* @var AdminModuleDataProvider
*/
private $addonsProvider;
/**
* @var ModuleRepositoryInterface
*/
private $moduleRepository;
/**
* @var PresenterInterface
*/
private $modulePresenter;
/**
* @var TabRepository
*/
private $tabRepository;
/**
* @var LegacyContext
*/
private $context;
/**
* Constructor.
*
* @param AdminModuleDataProvider $addonsProvider
* @param ModuleRepositoryInterface $moduleRepository
* @param PresenterInterface $modulePresenter
* @param TabRepository $tabRepository
* @param LegacyContext $context
*/
public function __construct(
AdminModuleDataProvider $addonsProvider,
ModuleRepositoryInterface $moduleRepository,
PresenterInterface $modulePresenter,
TabRepository $tabRepository,
LegacyContext $context
) {
$this->addonsProvider = $addonsProvider;
$this->moduleRepository = $moduleRepository;
$this->modulePresenter = $modulePresenter;
$this->tabRepository = $tabRepository;
$this->context = $context;
}
/**
* @param array $moduleNames
*
* @return array
*/
public function getData(array $moduleNames)
{
$data = [];
$modulesOnDisk = AddonsCollection::createFrom($this->moduleRepository->getList());
$modulesOnDisk = $this->addonsProvider->generateAddonsUrls($modulesOnDisk);
foreach ($modulesOnDisk as $module) {
/** @var \PrestaShop\PrestaShop\Adapter\Module\Module $module */
if (!in_array($module->get('name'), $moduleNames)) {
continue;
}
if ($module->get('id')) {
$isEmployeeAllowed = (bool) Module::getPermissionStatic(
$module->get('id'),
'configure',
$this->context->getContext()->employee
);
} else {
$ModuleTabId = $this->tabRepository->findOneIdByClassName('AdminModules');
/** @var array $access */
$access = Profile::getProfileAccess(
$this->context->getContext()->employee->id_profile,
$ModuleTabId
);
$isEmployeeAllowed = !$access['edit'];
}
if (false === $isEmployeeAllowed) {
continue;
}
if ($module->get('author') === ModuleRepository::PARTNER_AUTHOR) {
$module->set('type', 'addonsPartner');
}
$module->fillLogo();
$data[$module->get('name')] = $this->modulePresenter->present($module);
}
return $data;
}
}

View File

@@ -0,0 +1,77 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
namespace PrestaShop\Module\Mbo\RecommendedLink;
class RecommendedLink implements RecommendedLinkInterface
{
/**
* @var string
*/
private $id;
/**
* @var string
*/
private $url;
/**
* @var string
*/
private $name;
/**
* RecommendedLink constructor.
*
* @param string $id
* @param string $url
* @param string $name
*/
public function __construct($id, $url, $name)
{
$this->id = $id;
$this->url = $url;
$this->name = $name;
}
/**
* {@inheritdoc}
*/
public function getId()
{
return $this->id;
}
/**
* {@inheritdoc}
*/
public function getUrl()
{
return $this->url;
}
/**
* {@inheritdoc}
*/
public function getName()
{
return $this->name;
}
}

View File

@@ -0,0 +1,45 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
namespace PrestaShop\Module\Mbo\RecommendedLink;
interface RecommendedLinkInterface
{
/**
* Get the identifier of the recommended link.
*
* @return string
*/
public function getId();
/**
* Get the url of the recommended module.
*
* @return string
*/
public function getUrl();
/**
* Get the display name of the recommended module.
*
* @return string
*/
public function getName();
}

View File

@@ -0,0 +1,98 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
namespace PrestaShop\Module\Mbo\RecommendedLink;
use PrestaShop\PrestaShop\Adapter\LegacyContext;
use Symfony\Component\Serializer\SerializerInterface;
class RecommendedLinkProvider
{
/**
* @var LegacyContext
*/
private $context;
/**
* @var SerializerInterface
*/
private $serializer;
/**
* Constructor.
*
* @param SerializerInterface $serializer
* @param LegacyContext $context
*/
public function __construct(
LegacyContext $context,
SerializerInterface $serializer
) {
$this->context = $context;
$this->serializer = $serializer;
}
/**
* @return RecommendedLink[]
*/
public function getRecommendedLinks()
{
$recommendedLinks = [];
$cacheFile = $this->getCacheFile();
if ($cacheFile) {
$recommendedLinks = $this->serializer->deserialize(
file_get_contents($cacheFile),
sprintf('%s[]', RecommendedLink::class),
'json'
);
}
return $recommendedLinks;
}
/**
* Search a cache associated to context language or try to fallback to default locale
*
* @return string
*/
private function getCacheFile()
{
$cacheFile = _PS_MODULE_DIR_
. 'ps_mbo/cache/recommended-links-'
. strtolower($this->context->getContext()->language->iso_code)
. '.json'
;
if (file_exists($cacheFile)) {
return $cacheFile;
}
$cacheFile = _PS_MODULE_DIR_
. 'ps_mbo/cache/recommended-links-en.json'
;
if (file_exists($cacheFile)) {
return $cacheFile;
}
return '';
}
}

View File

@@ -0,0 +1,116 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
namespace PrestaShop\Module\Mbo\RecommendedModule;
class RecommendedModule implements RecommendedModuleInterface
{
/**
* @var string technical name of the recommended module
*/
private $moduleName;
/**
* @var int position of the recommended module
*/
private $position;
/**
* @var bool
*/
private $isInstalled;
/**
* @var array
*/
private $moduleData;
/**
* {@inheritdoc}
*/
public function getModuleName()
{
return $this->moduleName;
}
/**
* {@inheritdoc}
*/
public function setModuleName($moduleName)
{
$this->moduleName = $moduleName;
return $this;
}
/**
* {@inheritdoc}
*/
public function getPosition()
{
return $this->position;
}
/**
* {@inheritdoc}
*/
public function setPosition($position)
{
$this->position = $position;
return $this;
}
/**
* {@inheritdoc}
*/
public function isInstalled()
{
return $this->isInstalled;
}
/**
* {@inheritdoc}
*/
public function setInstalled($isInstalled)
{
$this->isInstalled = $isInstalled;
return $this;
}
/**
* {@inheritdoc}
*/
public function getModuleData()
{
return $this->moduleData;
}
/**
* {@inheritdoc}
*/
public function setModuleData($moduleData)
{
$this->moduleData = $moduleData;
return $this;
}
}

View File

@@ -0,0 +1,192 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
namespace PrestaShop\Module\Mbo\RecommendedModule;
use ArrayIterator;
use Closure;
class RecommendedModuleCollection implements RecommendedModuleCollectionInterface
{
/**
* @var RecommendedModuleInterface[]
*/
private $recommendedModules = [];
/**
* {@inheritdoc}
*/
public function addRecommendedModule(RecommendedModuleInterface $recommendedModule)
{
$this->recommendedModules[] = $recommendedModule;
return $this;
}
/**
* {@inheritdoc}
*/
public function getRecommendedModule($moduleName)
{
foreach ($this->recommendedModules as $recommendedModule) {
if ($moduleName === $recommendedModule->getModuleName()) {
return $recommendedModule;
}
}
return false;
}
/**
* {@inheritdoc}
*/
public function getRecommendedModuleNames()
{
$recommendedModuleNames = [];
foreach ($this->recommendedModules as $recommendedModule) {
$recommendedModuleNames[] = $recommendedModule->getModuleName();
}
return $recommendedModuleNames;
}
/**
* {@inheritdoc}
*/
public function offsetExists($offset)
{
return array_key_exists($offset, $this->recommendedModules);
}
/**
* {@inheritdoc}
*/
public function offsetGet($offset)
{
return $this->recommendedModules[$offset];
}
/**
* {@inheritdoc}
*/
public function offsetSet($offset, $value)
{
$this->recommendedModules[$offset] = $value;
}
/**
* {@inheritdoc}
*/
public function offsetUnset($offset)
{
unset($this->recommendedModules[$offset]);
}
/**
* {@inheritdoc}
*/
public function getIterator()
{
return new ArrayIterator($this->recommendedModules);
}
/**
* {@inheritdoc}
*/
public function count()
{
return count($this->recommendedModules);
}
/**
* {@inheritdoc}
*/
public function isEmpty()
{
return empty($this->recommendedModules);
}
/**
* {@inheritdoc}
*/
public function sortByPosition()
{
$this->sort(function (
RecommendedModuleInterface $recommendedModuleA,
RecommendedModuleInterface $recommendedModuleB
) {
if ($recommendedModuleA->getPosition() === $recommendedModuleB->getPosition()) {
return 0;
}
return ($recommendedModuleA->getPosition() < $recommendedModuleB->getPosition()) ? -1 : 1;
});
}
/**
* {@inheritdoc}
*/
public function getInstalled()
{
return $this->filter(function (RecommendedModuleInterface $recommendedModule) {
return $recommendedModule->isInstalled();
});
}
/**
* {@inheritdoc}
*/
public function getNotInstalled()
{
return $this->filter(function (RecommendedModuleInterface $recommendedModule) {
return !$recommendedModule->isInstalled();
});
}
/**
* @param Closure $closure
*
* @return RecommendedModuleCollection
*/
private function filter(Closure $closure)
{
$recommendedModules = new static();
$recommendedModules->recommendedModules = array_filter(
$this->recommendedModules,
$closure,
ARRAY_FILTER_USE_BOTH
);
$recommendedModules->sortByPosition();
return $recommendedModules;
}
/**
* @param Closure $closure
*/
private function sort(Closure $closure)
{
uasort(
$this->recommendedModules,
$closure
);
}
}

View File

@@ -0,0 +1,84 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
namespace PrestaShop\Module\Mbo\RecommendedModule;
use ArrayAccess;
use Countable;
use IteratorAggregate;
interface RecommendedModuleCollectionInterface extends ArrayAccess, IteratorAggregate, Countable
{
/**
* Add a recommended module to this collection.
*
* @param RecommendedModuleInterface $recommendedModule
*
* @return self
*/
public function addRecommendedModule(RecommendedModuleInterface $recommendedModule);
/**
* Get a recommended module by name
*
* @param string $moduleName
*
* @return RecommendedModuleInterface|false
*/
public function getRecommendedModule($moduleName);
/**
* Get names of recommended modules
*
* @return string[]
*/
public function getRecommendedModuleNames();
/**
* @param mixed $offset
*
* @return RecommendedModuleInterface
*/
public function offsetGet($offset);
/**
* @return bool
*/
public function isEmpty();
/**
* Sort recommended modules by position
*/
public function sortByPosition();
/**
* Get recommended modules installed.
*
* @return RecommendedModuleCollectionInterface
*/
public function getInstalled();
/**
* Get recommended modules not installed.
*
* @return RecommendedModuleCollectionInterface
*/
public function getNotInstalled();
}

View File

@@ -0,0 +1,80 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
namespace PrestaShop\Module\Mbo\RecommendedModule;
interface RecommendedModuleInterface
{
/**
* Get the technical name of the recommended module.
*
* @return string
*/
public function getModuleName();
/**
* @param string $moduleName
*
* @return RecommendedModuleInterface
*/
public function setModuleName($moduleName);
/**
* Get the position of the recommended module.
*
* @return int
*/
public function getPosition();
/**
* @param int $position
*
* @return RecommendedModuleInterface
*/
public function setPosition($position);
/**
* Check if the recommended modules is installed.
*
* @return bool
*/
public function isInstalled();
/**
* @param bool $isInstalled
*
* @return RecommendedModuleInterface
*/
public function setInstalled($isInstalled);
/**
* Get the recommended module data.
*
* @return array
*/
public function getModuleData();
/**
* @param array $moduleData
*
* @return RecommendedModuleInterface
*/
public function setModuleData($moduleData);
}

View File

@@ -0,0 +1,46 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
namespace PrestaShop\Module\Mbo\RecommendedModule;
class RecommendedModulePresenter implements RecommendedModulePresenterInterface
{
/**
* {@inheritdoc}
*/
public function present(RecommendedModuleInterface $recommendedModule)
{
return $recommendedModule->getModuleData();
}
/**
* {@inheritdoc}
*/
public function presentCollection(RecommendedModuleCollectionInterface $recommendedModules)
{
$recommendedModulesPresented = [];
foreach ($recommendedModules as $recommendedModule) {
$recommendedModulesPresented[] = $this->present($recommendedModule);
}
return $recommendedModulesPresented;
}
}

View File

@@ -0,0 +1,42 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
namespace PrestaShop\Module\Mbo\RecommendedModule;
interface RecommendedModulePresenterInterface
{
/**
* Transform a RecommendedModuleInterface as a simple array of data.
*
* @param RecommendedModuleInterface $recommendedModule
*
* @return array
*/
public function present(RecommendedModuleInterface $recommendedModule);
/**
* Transform a collection of RecommendedModulesInterface as a simple array of data.
*
* @param RecommendedModuleCollectionInterface $recommendedModules
*
* @return array
*/
public function presentCollection(RecommendedModuleCollectionInterface $recommendedModules);
}

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,158 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
namespace PrestaShop\Module\Mbo\Tab;
use PrestaShop\Module\Mbo\RecommendedModule\RecommendedModuleCollection;
use PrestaShop\Module\Mbo\RecommendedModule\RecommendedModuleCollectionInterface;
class Tab implements TabInterface
{
/**
* @var string class name of the tab
*/
private $legacyClassName;
/**
* @var string class name of the tab
*/
private $displayMode;
/**
* @var RecommendedModuleCollectionInterface recommended modules of the tab
*/
private $recommendedModules;
/**
* Tab constructor.
*/
public function __construct()
{
$this->recommendedModules = new RecommendedModuleCollection();
}
/**
* {@inheritdoc}
*/
public function getLegacyClassName()
{
return $this->legacyClassName;
}
/**
* {@inheritdoc}
*/
public function setLegacyClassName($legacyClassName)
{
$this->legacyClassName = $legacyClassName;
return $this;
}
/**
* {@inheritdoc}
*/
public function getDisplayMode()
{
return $this->displayMode;
}
/**
* {@inheritdoc}
*/
public function setDisplayMode($displayMode)
{
$this->displayMode = $displayMode;
return $this;
}
/**
* {@inheritdoc}
*/
public function getRecommendedModules()
{
return $this->recommendedModules;
}
/**
* {@inheritdoc}
*/
public function setRecommendedModules(RecommendedModuleCollectionInterface $recommendedModules)
{
$this->recommendedModules = $recommendedModules;
return $this;
}
/**
* {@inheritdoc}
*/
public function hasRecommendedModules()
{
return !$this->recommendedModules->isEmpty();
}
/**
* {@inheritdoc}
*/
public function getRecommendedModulesInstalled()
{
$recommendedModulesInstalled = $this->getRecommendedModules();
if ($this->hasRecommendedModules()) {
return $recommendedModulesInstalled->getInstalled();
}
return $recommendedModulesInstalled;
}
/**
* {@inheritdoc}
*/
public function getRecommendedModulesNotInstalled()
{
$recommendedModulesNotInstalled = $this->getRecommendedModules();
if ($this->hasRecommendedModules()) {
return $recommendedModulesNotInstalled->getNotInstalled();
}
return $recommendedModulesNotInstalled;
}
/**
* {@inheritdoc}
*/
public function shouldDisplayButton()
{
return $this->hasRecommendedModules()
&& TabInterface::DISPLAY_MODE_MODAL === $this->getDisplayMode();
}
/**
* {@inheritdoc}
*/
public function shouldDisplayAfterContent()
{
return $this->hasRecommendedModules()
&& TabInterface::DISPLAY_MODE_AFTER_CONTENT === $this->getDisplayMode();
}
}

View File

@@ -0,0 +1,111 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
namespace PrestaShop\Module\Mbo\Tab;
use ArrayIterator;
class TabCollection implements TabCollectionInterface
{
/**
* @var TabInterface[]
*/
private $tabs = [];
/**
* {@inheritdoc}
*/
public function addTab(TabInterface $tab)
{
$this->tabs[] = $tab;
return $this;
}
/**
* {@inheritdoc}
*/
public function getTab($tabClassName)
{
foreach ($this->tabs as $tab) {
if ($tabClassName === $tab->getLegacyClassName()) {
return $tab;
}
}
return new Tab();
}
/**
* {@inheritdoc}
*/
public function offsetExists($offset)
{
return array_key_exists($offset, $this->tabs);
}
/**
* {@inheritdoc}
*/
public function offsetSet($offset, $value)
{
$this->tabs[$offset] = $value;
}
/**
* {@inheritdoc}
*/
public function offsetGet($offset)
{
return $this->tabs[$offset];
}
/**
* {@inheritdoc}
*/
public function offsetUnset($offset)
{
unset($this->tabs[$offset]);
}
/**
* {@inheritdoc}
*/
public function getIterator()
{
return new ArrayIterator($this->tabs);
}
/**
* {@inheritdoc}
*/
public function count()
{
return count($this->tabs);
}
/**
* {@inheritdoc}
*/
public function isEmpty()
{
return empty($this->tabs);
}
}

View File

@@ -0,0 +1,83 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
namespace PrestaShop\Module\Mbo\Tab;
class TabCollectionDecoderXml
{
private $content;
/**
* Constructor.
*
* @param string $content
*/
public function __construct($content)
{
$this->content = $content;
}
/**
* @return array
*/
public function toArray()
{
$data = [];
if (empty($this->content)) {
return $data;
}
$simpleXMLElement = @simplexml_load_string($this->content);
if (false === $simpleXMLElement
|| !isset($simpleXMLElement->tab)
) {
return $data;
}
foreach ($simpleXMLElement->tab as $tab) {
$tabClassName = null;
$tabDisplayMode = 'slider_list';
$tabRecommendedModules = [];
foreach ($tab->attributes() as $key => $value) {
if ('class_name' === $key) {
$tabClassName = (string) $value;
}
if ('display_type' === $key) {
$tabDisplayMode = (string) $value;
}
}
foreach ($tab->children() as $module) {
if (isset($module['position'], $module['name'])) {
$tabRecommendedModules[(int) $module['position']] = (string) $module['name'];
}
}
if (!empty($tabClassName)) {
$data[$tabClassName] = [
'displayMode' => $tabDisplayMode,
'recommendedModules' => $tabRecommendedModules,
];
}
}
return $data;
}
}

View File

@@ -0,0 +1,104 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
namespace PrestaShop\Module\Mbo\Tab;
use PrestaShop\Module\Mbo\ModuleCollectionDataProvider;
use PrestaShop\Module\Mbo\RecommendedModule\RecommendedModule;
use PrestaShop\Module\Mbo\RecommendedModule\RecommendedModuleCollection;
class TabCollectionFactory implements TabCollectionFactoryInterface
{
private $moduleCollectionDataProvider;
/**
* Constructor.
*
* @param ModuleCollectionDataProvider $moduleCollectionDataProvider
*/
public function __construct(ModuleCollectionDataProvider $moduleCollectionDataProvider)
{
$this->moduleCollectionDataProvider = $moduleCollectionDataProvider;
}
/**
* {@inheritdoc}
*/
public function buildFromArray(array $data)
{
$tabCollection = new TabCollection();
if (empty($data)) {
return $tabCollection;
}
$modulesData = $this->moduleCollectionDataProvider->getData($this->getModuleNames($data));
if (empty($modulesData)) {
return $tabCollection;
}
foreach ($data as $tabClassName => $tabData) {
$recommendedModuleCollection = new RecommendedModuleCollection();
foreach ($tabData['recommendedModules'] as $position => $moduleName) {
if (isset($modulesData[$moduleName])) {
$recommendedModule = new RecommendedModule();
$recommendedModule->setModuleName($moduleName);
$recommendedModule->setPosition((int) $position);
$recommendedModule->setInstalled((bool) $modulesData[$moduleName]['database']['installed']);
$recommendedModule->setModuleData($modulesData[$moduleName]);
$recommendedModuleCollection->addRecommendedModule($recommendedModule);
}
}
if (!$recommendedModuleCollection->isEmpty()) {
$recommendedModuleCollection->sortByPosition();
$tab = new Tab();
$tab->setLegacyClassName($tabClassName);
$tab->setDisplayMode($tabData['displayMode']);
$tab->setRecommendedModules($recommendedModuleCollection);
$tabCollection->addTab($tab);
}
}
return $tabCollection;
}
/**
* @param array $data
*
* @return string[]
*/
private function getModuleNames(array $data)
{
$moduleNames = [];
foreach ($data as $tabData) {
foreach ($tabData['recommendedModules'] as $moduleName) {
$moduleNames[] = $moduleName;
}
}
return array_unique($moduleNames);
}
}

View File

@@ -0,0 +1,33 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
namespace PrestaShop\Module\Mbo\Tab;
interface TabCollectionFactoryInterface
{
/**
* Builds a tabs recommended modules collection from an array.
*
* @param array $data
*
* @return TabCollectionInterface
*/
public function buildFromArray(array $data);
}

View File

@@ -0,0 +1,56 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
namespace PrestaShop\Module\Mbo\Tab;
use ArrayAccess;
use Countable;
use IteratorAggregate;
interface TabCollectionInterface extends ArrayAccess, IteratorAggregate, Countable
{
/**
* Add a tab to this collection.
*
* @param TabInterface $tab
*
* @return self
*/
public function addTab(TabInterface $tab);
/**
* @param string $tabClassName
*
* @return TabInterface
*/
public function getTab($tabClassName);
/**
* @param mixed $offset
*
* @return TabInterface
*/
public function offsetGet($offset);
/**
* @return bool
*/
public function isEmpty();
}

View File

@@ -0,0 +1,128 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
namespace PrestaShop\Module\Mbo\Tab;
use Doctrine\Common\Cache\CacheProvider;
use PrestaShop\Module\Mbo\ExternalContentProvider\ExternalContentProviderInterface;
use PrestaShop\PrestaShop\Adapter\LegacyContext;
use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException;
class TabCollectionProvider implements TabCollectionProviderInterface
{
const CACHE_KEY = 'recommendedModules';
const CACHE_LIFETIME_SECONDS = 604800;
const API_URL = 'https://api.prestashop.com/xml/tab_modules_list_17.xml';
/**
* @var LegacyContext
*/
private $context;
/**
* @var ExternalContentProviderInterface
*/
private $externalContentProvider;
/**
* @var TabCollectionFactoryInterface
*/
private $tabCollectionFactory;
/**
* @var CacheProvider|null
*/
private $cacheProvider;
/**
* @param LegacyContext $context
* @param ExternalContentProviderInterface $externalContentProvider
* @param TabCollectionFactoryInterface $tabCollectionFactory
* @param CacheProvider|null $cacheProvider
*/
public function __construct(
LegacyContext $context,
ExternalContentProviderInterface $externalContentProvider,
TabCollectionFactoryInterface $tabCollectionFactory,
CacheProvider $cacheProvider = null
) {
$this->context = $context;
$this->externalContentProvider = $externalContentProvider;
$this->tabCollectionFactory = $tabCollectionFactory;
$this->cacheProvider = $cacheProvider;
}
/**
* {@inheritdoc}
*/
public function getTabCollection()
{
if ($this->isTabCollectionCached()) {
return $this->cacheProvider->fetch($this->getCacheKey());
}
$tabCollection = $this->getTabCollectionFromApi();
if ($this->cacheProvider
&& false === $tabCollection->isEmpty()
) {
$this->cacheProvider->save(
$this->getCacheKey(),
$tabCollection,
static::CACHE_LIFETIME_SECONDS
);
}
return $tabCollection;
}
private function getCacheKey()
{
return static::CACHE_KEY . '-' . $this->context->getEmployeeLanguageIso();
}
/**
* Check if recommended modules cache is set
*
* @return bool
*/
public function isTabCollectionCached()
{
return $this->cacheProvider
&& $this->cacheProvider->contains($this->getCacheKey());
}
/**
* Retrieve tabs with recommended modules from PrestaShop
*
* @return TabCollectionInterface
*
* @throws ServiceUnavailableHttpException
*/
private function getTabCollectionFromApi()
{
$apiResponse = $this->externalContentProvider->getContent(self::API_URL);
$tabCollectionDecoderXml = new TabCollectionDecoderXml($apiResponse);
return $this->tabCollectionFactory->buildFromArray($tabCollectionDecoderXml->toArray());
}
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
namespace PrestaShop\Module\Mbo\Tab;
interface TabCollectionProviderInterface
{
/**
* @return TabCollectionInterface
*/
public function getTabCollection();
}

View File

@@ -0,0 +1,103 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
namespace PrestaShop\Module\Mbo\Tab;
use PrestaShop\Module\Mbo\RecommendedModule\RecommendedModuleCollectionInterface;
interface TabInterface
{
const DISPLAY_MODE_MODAL = 'slider_list';
const DISPLAY_MODE_AFTER_CONTENT = 'default_list';
/**
* Get the class name of the tab.
*
* @return string
*/
public function getLegacyClassName();
/**
* @param string $legacyClassName
*
* @return TabInterface
*/
public function setLegacyClassName($legacyClassName);
/**
* Get the display mode of the tab.
*
* @return string
*/
public function getDisplayMode();
/**
* @param string $displayMode
*
* @return TabInterface
*/
public function setDisplayMode($displayMode);
/**
* Get the recommended modules of the tab.
*
* @return RecommendedModuleCollectionInterface
*/
public function getRecommendedModules();
/**
* @param RecommendedModuleCollectionInterface $recommendedModules
*
* @return TabInterface
*/
public function setRecommendedModules(RecommendedModuleCollectionInterface $recommendedModules);
/**
* Check if the tab has recommended modules.
*
* @return bool
*/
public function hasRecommendedModules();
/**
* Get the installed recommended modules of the tab.
*
* @return RecommendedModuleCollectionInterface
*/
public function getRecommendedModulesInstalled();
/**
* Get the not installed recommended modules of the tab.
*
* @return RecommendedModuleCollectionInterface
*/
public function getRecommendedModulesNotInstalled();
/**
* @return bool
*/
public function shouldDisplayButton();
/**
* @return bool
*/
public function shouldDisplayAfterContent();
}

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,93 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
$rootDir = getenv('_PS_ROOT_DIR_');
if (!$rootDir) {
echo '[ERROR] Define _PS_ROOT_DIR_ with the path to PrestaShop folder' . PHP_EOL;
exit(1);
}
$pathToModuleRoot = __DIR__ . '/../../';
// Add module composer autoloader
require_once $pathToModuleRoot . 'vendor/autoload.php';
// Add PrestaShop composer autoload
define('_PS_ADMIN_DIR_', $rootDir . '/admin-dev/');
define('PS_ADMIN_DIR', _PS_ADMIN_DIR_);
require_once $rootDir . '/config/defines.inc.php';
require_once $rootDir . '/config/autoload.php';
require_once $rootDir . '/config/bootstrap.php';
// Make sure loader php-parser is coming from php stan composer
// 1- Use with Docker container
$loader = new \Composer\Autoload\ClassLoader();
$loader->setPsr4('PhpParser\\', ['/composer/vendor/nikic/php-parser/lib/PhpParser']);
$loader->register(true);
// 2- Use with PHPStan phar
$loader = new \Composer\Autoload\ClassLoader();
// Contains the vendor in phar, like "phar://phpstan.phar/vendor"
$loader->setPsr4('PhpParser\\', ['phar://' . dirname($_SERVER['PATH_TRANSLATED']) . '/../phpstan/phpstan-shim/phpstan.phar/vendor/nikic/php-parser/lib/PhpParser/']);
$loader->register(true);
// We must declare these constant in this boostrap script.
// Ignoring the error partern with this value will throw another error if not found
// during the checks.
$constantsToDefine = [
'_DB_SERVER_',
'_DB_NAME_',
'_DB_USER_',
'_DB_PASSWD_',
'_MYSQL_ENGINE_',
'_COOKIE_KEY_',
'_COOKIE_IV_',
'_PS_VERSION_',
'_DB_PREFIX_',
'_PS_SSL_PORT_',
'_THEME_NAME_',
'_THEME_COL_DIR_',
'_PARENT_THEME_NAME_',
'__PS_BASE_URI__',
'_MODULE_DIR_',
'_PS_PRICE_DISPLAY_PRECISION_',
'_PS_PRICE_COMPUTE_PRECISION_',
'_PS_OS_CHEQUE_',
'_PS_OS_PAYMENT_',
'_PS_OS_PREPARATION_',
'_PS_OS_SHIPPING_',
'_PS_OS_DELIVERED_',
'_PS_OS_CANCELED_',
'_PS_OS_REFUND_',
'_PS_OS_ERROR_',
'_PS_OS_OUTOFSTOCK_',
'_PS_OS_OUTOFSTOCK_PAID_',
'_PS_OS_OUTOFSTOCK_UNPAID_',
'_PS_OS_BANKWIRE_',
'_PS_OS_PAYPAL_',
'_PS_OS_WS_PAYMENT_',
'_PS_OS_COD_VALIDATION_',
];
foreach ($constantsToDefine as $constant) {
if (!defined($constant)) {
define($constant, 'DUMMY_VALUE');
}
}

View File

@@ -0,0 +1,13 @@
parameters:
bootstrap: tests/phpstan/bootstrap.php
paths:
- src
- ps_mbo.php
dynamicConstantNames:
- _PS_VERSION_
ignoreErrors:
- '#Property ModuleCore::\$version \(float\) does not accept string.#'
- '#Parameter \#2 \$variable of static method ModuleCore::getPermissionStatic\(\) expects array, string given.#'
- '#Parameter \#1 \$idProfile of static method ProfileCore::getProfileAccess\(\) expects int, string given.#'
level: 5

View File

@@ -0,0 +1,28 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,64 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
/**
* @param ps_mbo $module
*
* @return bool
*/
function upgrade_module_2_0_0($module)
{
// Retrieve all hooks registered with MBO
$hookData = Db::getInstance()->executeS('
SELECT DISTINCT(`id_hook`)
FROM `' . _DB_PREFIX_ . 'hook_module`
WHERE `id_module` = ' . (int) $module->id
);
// Some hooks are no longer used, we unregister them.
if (!empty($hookData)) {
foreach ($hookData as $row) {
if (false === $module->unregisterHook((int) $row['id_hook'])) {
return false;
}
if (false === $module->unregisterExceptions((int) $row['id_hook'])) {
return false;
}
}
}
// Some hooks are added, we register them.
if (false === $module->registerHook(ps_mbo::HOOKS)) {
return false;
}
// We migrate Module Selections Tab to MBO
if (false === $module->installTab(ps_mbo::ADMIN_CONTROLLERS['AdminPsMboAddons'])) {
return false;
}
// We create Module Recommended Tab to MBO
if (false === $module->installTab(ps_mbo::ADMIN_CONTROLLERS['AdminPsMboRecommended'])) {
return false;
}
return true;
}

10
modules/ps_mbo/vendor/.htaccess vendored Normal file
View File

@@ -0,0 +1,10 @@
# Apache 2.2
<IfModule !mod_authz_core.c>
Order deny,allow
Deny from all
</IfModule>
# Apache 2.4
<IfModule mod_authz_core.c>
Require all denied
</IfModule>

7
modules/ps_mbo/vendor/autoload.php vendored Normal file
View File

@@ -0,0 +1,7 @@
<?php
// autoload.php @generated by Composer
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit3e44735d963ebd3a608c6dbc44a70076::getLoader();

View File

@@ -0,0 +1,445 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Autoload;
/**
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
*
* $loader = new \Composer\Autoload\ClassLoader();
*
* // register classes with namespaces
* $loader->add('Symfony\Component', __DIR__.'/component');
* $loader->add('Symfony', __DIR__.'/framework');
*
* // activate the autoloader
* $loader->register();
*
* // to enable searching the include path (eg. for PEAR packages)
* $loader->setUseIncludePath(true);
*
* In this example, if you try to use a class in the Symfony\Component
* namespace or one of its children (Symfony\Component\Console for instance),
* the autoloader will first look for the class under the component/
* directory, and it will then fallback to the framework/ directory if not
* found before giving up.
*
* This class is loosely based on the Symfony UniversalClassLoader.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Jordi Boggiano <j.boggiano@seld.be>
* @see http://www.php-fig.org/psr/psr-0/
* @see http://www.php-fig.org/psr/psr-4/
*/
class ClassLoader
{
// PSR-4
private $prefixLengthsPsr4 = array();
private $prefixDirsPsr4 = array();
private $fallbackDirsPsr4 = array();
// PSR-0
private $prefixesPsr0 = array();
private $fallbackDirsPsr0 = array();
private $useIncludePath = false;
private $classMap = array();
private $classMapAuthoritative = false;
private $missingClasses = array();
private $apcuPrefix;
public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
return call_user_func_array('array_merge', $this->prefixesPsr0);
}
return array();
}
public function getPrefixesPsr4()
{
return $this->prefixDirsPsr4;
}
public function getFallbackDirs()
{
return $this->fallbackDirsPsr0;
}
public function getFallbackDirsPsr4()
{
return $this->fallbackDirsPsr4;
}
public function getClassMap()
{
return $this->classMap;
}
/**
* @param array $classMap Class to filename map
*/
public function addClassMap(array $classMap)
{
if ($this->classMap) {
$this->classMap = array_merge($this->classMap, $classMap);
} else {
$this->classMap = $classMap;
}
}
/**
* Registers a set of PSR-0 directories for a given prefix, either
* appending or prepending to the ones previously set for this prefix.
*
* @param string $prefix The prefix
* @param array|string $paths The PSR-0 root directories
* @param bool $prepend Whether to prepend the directories
*/
public function add($prefix, $paths, $prepend = false)
{
if (!$prefix) {
if ($prepend) {
$this->fallbackDirsPsr0 = array_merge(
(array) $paths,
$this->fallbackDirsPsr0
);
} else {
$this->fallbackDirsPsr0 = array_merge(
$this->fallbackDirsPsr0,
(array) $paths
);
}
return;
}
$first = $prefix[0];
if (!isset($this->prefixesPsr0[$first][$prefix])) {
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
return;
}
if ($prepend) {
$this->prefixesPsr0[$first][$prefix] = array_merge(
(array) $paths,
$this->prefixesPsr0[$first][$prefix]
);
} else {
$this->prefixesPsr0[$first][$prefix] = array_merge(
$this->prefixesPsr0[$first][$prefix],
(array) $paths
);
}
}
/**
* Registers a set of PSR-4 directories for a given namespace, either
* appending or prepending to the ones previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-4 base directories
* @param bool $prepend Whether to prepend the directories
*
* @throws \InvalidArgumentException
*/
public function addPsr4($prefix, $paths, $prepend = false)
{
if (!$prefix) {
// Register directories for the root namespace.
if ($prepend) {
$this->fallbackDirsPsr4 = array_merge(
(array) $paths,
$this->fallbackDirsPsr4
);
} else {
$this->fallbackDirsPsr4 = array_merge(
$this->fallbackDirsPsr4,
(array) $paths
);
}
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
// Register directories for a new namespace.
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
} elseif ($prepend) {
// Prepend directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
(array) $paths,
$this->prefixDirsPsr4[$prefix]
);
} else {
// Append directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
$this->prefixDirsPsr4[$prefix],
(array) $paths
);
}
}
/**
* Registers a set of PSR-0 directories for a given prefix,
* replacing any others previously set for this prefix.
*
* @param string $prefix The prefix
* @param array|string $paths The PSR-0 base directories
*/
public function set($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr0 = (array) $paths;
} else {
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
}
}
/**
* Registers a set of PSR-4 directories for a given namespace,
* replacing any others previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-4 base directories
*
* @throws \InvalidArgumentException
*/
public function setPsr4($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr4 = (array) $paths;
} else {
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
}
}
/**
* Turns on searching the include path for class files.
*
* @param bool $useIncludePath
*/
public function setUseIncludePath($useIncludePath)
{
$this->useIncludePath = $useIncludePath;
}
/**
* Can be used to check if the autoloader uses the include path to check
* for classes.
*
* @return bool
*/
public function getUseIncludePath()
{
return $this->useIncludePath;
}
/**
* Turns off searching the prefix and fallback directories for classes
* that have not been registered with the class map.
*
* @param bool $classMapAuthoritative
*/
public function setClassMapAuthoritative($classMapAuthoritative)
{
$this->classMapAuthoritative = $classMapAuthoritative;
}
/**
* Should class lookup fail if not found in the current class map?
*
* @return bool
*/
public function isClassMapAuthoritative()
{
return $this->classMapAuthoritative;
}
/**
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
*
* @param string|null $apcuPrefix
*/
public function setApcuPrefix($apcuPrefix)
{
$this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null;
}
/**
* The APCu prefix in use, or null if APCu caching is not enabled.
*
* @return string|null
*/
public function getApcuPrefix()
{
return $this->apcuPrefix;
}
/**
* Registers this instance as an autoloader.
*
* @param bool $prepend Whether to prepend the autoloader or not
*/
public function register($prepend = false)
{
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
}
/**
* Unregisters this instance as an autoloader.
*/
public function unregister()
{
spl_autoload_unregister(array($this, 'loadClass'));
}
/**
* Loads the given class or interface.
*
* @param string $class The name of the class
* @return bool|null True if loaded, null otherwise
*/
public function loadClass($class)
{
if ($file = $this->findFile($class)) {
includeFile($file);
return true;
}
}
/**
* Finds the path to the file where the class is defined.
*
* @param string $class The name of the class
*
* @return string|false The path if found, false otherwise
*/
public function findFile($class)
{
// class map lookup
if (isset($this->classMap[$class])) {
return $this->classMap[$class];
}
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
return false;
}
if (null !== $this->apcuPrefix) {
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
if ($hit) {
return $file;
}
}
$file = $this->findFileWithExtension($class, '.php');
// Search for Hack files if we are running on HHVM
if (false === $file && defined('HHVM_VERSION')) {
$file = $this->findFileWithExtension($class, '.hh');
}
if (null !== $this->apcuPrefix) {
apcu_add($this->apcuPrefix.$class, $file);
}
if (false === $file) {
// Remember that this class does not exist.
$this->missingClasses[$class] = true;
}
return $file;
}
private function findFileWithExtension($class, $ext)
{
// PSR-4 lookup
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
$first = $class[0];
if (isset($this->prefixLengthsPsr4[$first])) {
$subPath = $class;
while (false !== $lastPos = strrpos($subPath, '\\')) {
$subPath = substr($subPath, 0, $lastPos);
$search = $subPath.'\\';
if (isset($this->prefixDirsPsr4[$search])) {
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
foreach ($this->prefixDirsPsr4[$search] as $dir) {
if (file_exists($file = $dir . $pathEnd)) {
return $file;
}
}
}
}
}
// PSR-4 fallback dirs
foreach ($this->fallbackDirsPsr4 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
return $file;
}
}
// PSR-0 lookup
if (false !== $pos = strrpos($class, '\\')) {
// namespaced class name
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
} else {
// PEAR-like class name
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
}
if (isset($this->prefixesPsr0[$first])) {
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
if (0 === strpos($class, $prefix)) {
foreach ($dirs as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
}
}
}
// PSR-0 fallback dirs
foreach ($this->fallbackDirsPsr0 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
// PSR-0 include paths.
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
return $file;
}
return false;
}
}
/**
* Scope isolated include.
*
* Prevents access to $this/self from included files.
*/
function includeFile($file)
{
include $file;
}

21
modules/ps_mbo/vendor/composer/LICENSE vendored Normal file
View File

@@ -0,0 +1,21 @@
Copyright (c) Nils Adermann, Jordi Boggiano
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,198 @@
<?php
// autoload_classmap.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'GuzzleHttp\\BatchResults' => $vendorDir . '/guzzlehttp/guzzle/src/BatchResults.php',
'GuzzleHttp\\Client' => $vendorDir . '/guzzlehttp/guzzle/src/Client.php',
'GuzzleHttp\\ClientInterface' => $vendorDir . '/guzzlehttp/guzzle/src/ClientInterface.php',
'GuzzleHttp\\Collection' => $vendorDir . '/guzzlehttp/guzzle/src/Collection.php',
'GuzzleHttp\\Cookie\\CookieJar' => $vendorDir . '/guzzlehttp/guzzle/src/Cookie/CookieJar.php',
'GuzzleHttp\\Cookie\\CookieJarInterface' => $vendorDir . '/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php',
'GuzzleHttp\\Cookie\\FileCookieJar' => $vendorDir . '/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php',
'GuzzleHttp\\Cookie\\SessionCookieJar' => $vendorDir . '/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php',
'GuzzleHttp\\Cookie\\SetCookie' => $vendorDir . '/guzzlehttp/guzzle/src/Cookie/SetCookie.php',
'GuzzleHttp\\Event\\AbstractEvent' => $vendorDir . '/guzzlehttp/guzzle/src/Event/AbstractEvent.php',
'GuzzleHttp\\Event\\AbstractRequestEvent' => $vendorDir . '/guzzlehttp/guzzle/src/Event/AbstractRequestEvent.php',
'GuzzleHttp\\Event\\AbstractRetryableEvent' => $vendorDir . '/guzzlehttp/guzzle/src/Event/AbstractRetryableEvent.php',
'GuzzleHttp\\Event\\AbstractTransferEvent' => $vendorDir . '/guzzlehttp/guzzle/src/Event/AbstractTransferEvent.php',
'GuzzleHttp\\Event\\BeforeEvent' => $vendorDir . '/guzzlehttp/guzzle/src/Event/BeforeEvent.php',
'GuzzleHttp\\Event\\CompleteEvent' => $vendorDir . '/guzzlehttp/guzzle/src/Event/CompleteEvent.php',
'GuzzleHttp\\Event\\Emitter' => $vendorDir . '/guzzlehttp/guzzle/src/Event/Emitter.php',
'GuzzleHttp\\Event\\EmitterInterface' => $vendorDir . '/guzzlehttp/guzzle/src/Event/EmitterInterface.php',
'GuzzleHttp\\Event\\EndEvent' => $vendorDir . '/guzzlehttp/guzzle/src/Event/EndEvent.php',
'GuzzleHttp\\Event\\ErrorEvent' => $vendorDir . '/guzzlehttp/guzzle/src/Event/ErrorEvent.php',
'GuzzleHttp\\Event\\EventInterface' => $vendorDir . '/guzzlehttp/guzzle/src/Event/EventInterface.php',
'GuzzleHttp\\Event\\HasEmitterInterface' => $vendorDir . '/guzzlehttp/guzzle/src/Event/HasEmitterInterface.php',
'GuzzleHttp\\Event\\HasEmitterTrait' => $vendorDir . '/guzzlehttp/guzzle/src/Event/HasEmitterTrait.php',
'GuzzleHttp\\Event\\ListenerAttacherTrait' => $vendorDir . '/guzzlehttp/guzzle/src/Event/ListenerAttacherTrait.php',
'GuzzleHttp\\Event\\ProgressEvent' => $vendorDir . '/guzzlehttp/guzzle/src/Event/ProgressEvent.php',
'GuzzleHttp\\Event\\RequestEvents' => $vendorDir . '/guzzlehttp/guzzle/src/Event/RequestEvents.php',
'GuzzleHttp\\Event\\SubscriberInterface' => $vendorDir . '/guzzlehttp/guzzle/src/Event/SubscriberInterface.php',
'GuzzleHttp\\Exception\\BadResponseException' => $vendorDir . '/guzzlehttp/guzzle/src/Exception/BadResponseException.php',
'GuzzleHttp\\Exception\\ClientException' => $vendorDir . '/guzzlehttp/guzzle/src/Exception/ClientException.php',
'GuzzleHttp\\Exception\\ConnectException' => $vendorDir . '/guzzlehttp/guzzle/src/Exception/ConnectException.php',
'GuzzleHttp\\Exception\\CouldNotRewindStreamException' => $vendorDir . '/guzzlehttp/guzzle/src/Exception/CouldNotRewindStreamException.php',
'GuzzleHttp\\Exception\\ParseException' => $vendorDir . '/guzzlehttp/guzzle/src/Exception/ParseException.php',
'GuzzleHttp\\Exception\\RequestException' => $vendorDir . '/guzzlehttp/guzzle/src/Exception/RequestException.php',
'GuzzleHttp\\Exception\\ServerException' => $vendorDir . '/guzzlehttp/guzzle/src/Exception/ServerException.php',
'GuzzleHttp\\Exception\\StateException' => $vendorDir . '/guzzlehttp/guzzle/src/Exception/StateException.php',
'GuzzleHttp\\Exception\\TooManyRedirectsException' => $vendorDir . '/guzzlehttp/guzzle/src/Exception/TooManyRedirectsException.php',
'GuzzleHttp\\Exception\\TransferException' => $vendorDir . '/guzzlehttp/guzzle/src/Exception/TransferException.php',
'GuzzleHttp\\Exception\\XmlParseException' => $vendorDir . '/guzzlehttp/guzzle/src/Exception/XmlParseException.php',
'GuzzleHttp\\HasDataTrait' => $vendorDir . '/guzzlehttp/guzzle/src/HasDataTrait.php',
'GuzzleHttp\\Message\\AbstractMessage' => $vendorDir . '/guzzlehttp/guzzle/src/Message/AbstractMessage.php',
'GuzzleHttp\\Message\\AppliesHeadersInterface' => $vendorDir . '/guzzlehttp/guzzle/src/Message/AppliesHeadersInterface.php',
'GuzzleHttp\\Message\\FutureResponse' => $vendorDir . '/guzzlehttp/guzzle/src/Message/FutureResponse.php',
'GuzzleHttp\\Message\\MessageFactory' => $vendorDir . '/guzzlehttp/guzzle/src/Message/MessageFactory.php',
'GuzzleHttp\\Message\\MessageFactoryInterface' => $vendorDir . '/guzzlehttp/guzzle/src/Message/MessageFactoryInterface.php',
'GuzzleHttp\\Message\\MessageInterface' => $vendorDir . '/guzzlehttp/guzzle/src/Message/MessageInterface.php',
'GuzzleHttp\\Message\\MessageParser' => $vendorDir . '/guzzlehttp/guzzle/src/Message/MessageParser.php',
'GuzzleHttp\\Message\\Request' => $vendorDir . '/guzzlehttp/guzzle/src/Message/Request.php',
'GuzzleHttp\\Message\\RequestInterface' => $vendorDir . '/guzzlehttp/guzzle/src/Message/RequestInterface.php',
'GuzzleHttp\\Message\\Response' => $vendorDir . '/guzzlehttp/guzzle/src/Message/Response.php',
'GuzzleHttp\\Message\\ResponseInterface' => $vendorDir . '/guzzlehttp/guzzle/src/Message/ResponseInterface.php',
'GuzzleHttp\\Mimetypes' => $vendorDir . '/guzzlehttp/guzzle/src/Mimetypes.php',
'GuzzleHttp\\Pool' => $vendorDir . '/guzzlehttp/guzzle/src/Pool.php',
'GuzzleHttp\\Post\\MultipartBody' => $vendorDir . '/guzzlehttp/guzzle/src/Post/MultipartBody.php',
'GuzzleHttp\\Post\\PostBody' => $vendorDir . '/guzzlehttp/guzzle/src/Post/PostBody.php',
'GuzzleHttp\\Post\\PostBodyInterface' => $vendorDir . '/guzzlehttp/guzzle/src/Post/PostBodyInterface.php',
'GuzzleHttp\\Post\\PostFile' => $vendorDir . '/guzzlehttp/guzzle/src/Post/PostFile.php',
'GuzzleHttp\\Post\\PostFileInterface' => $vendorDir . '/guzzlehttp/guzzle/src/Post/PostFileInterface.php',
'GuzzleHttp\\Query' => $vendorDir . '/guzzlehttp/guzzle/src/Query.php',
'GuzzleHttp\\QueryParser' => $vendorDir . '/guzzlehttp/guzzle/src/QueryParser.php',
'GuzzleHttp\\RequestFsm' => $vendorDir . '/guzzlehttp/guzzle/src/RequestFsm.php',
'GuzzleHttp\\RingBridge' => $vendorDir . '/guzzlehttp/guzzle/src/RingBridge.php',
'GuzzleHttp\\Ring\\Client\\ClientUtils' => $vendorDir . '/guzzlehttp/ringphp/src/Client/ClientUtils.php',
'GuzzleHttp\\Ring\\Client\\CurlFactory' => $vendorDir . '/guzzlehttp/ringphp/src/Client/CurlFactory.php',
'GuzzleHttp\\Ring\\Client\\CurlHandler' => $vendorDir . '/guzzlehttp/ringphp/src/Client/CurlHandler.php',
'GuzzleHttp\\Ring\\Client\\CurlMultiHandler' => $vendorDir . '/guzzlehttp/ringphp/src/Client/CurlMultiHandler.php',
'GuzzleHttp\\Ring\\Client\\Middleware' => $vendorDir . '/guzzlehttp/ringphp/src/Client/Middleware.php',
'GuzzleHttp\\Ring\\Client\\MockHandler' => $vendorDir . '/guzzlehttp/ringphp/src/Client/MockHandler.php',
'GuzzleHttp\\Ring\\Client\\StreamHandler' => $vendorDir . '/guzzlehttp/ringphp/src/Client/StreamHandler.php',
'GuzzleHttp\\Ring\\Core' => $vendorDir . '/guzzlehttp/ringphp/src/Core.php',
'GuzzleHttp\\Ring\\Exception\\CancelledException' => $vendorDir . '/guzzlehttp/ringphp/src/Exception/CancelledException.php',
'GuzzleHttp\\Ring\\Exception\\CancelledFutureAccessException' => $vendorDir . '/guzzlehttp/ringphp/src/Exception/CancelledFutureAccessException.php',
'GuzzleHttp\\Ring\\Exception\\ConnectException' => $vendorDir . '/guzzlehttp/ringphp/src/Exception/ConnectException.php',
'GuzzleHttp\\Ring\\Exception\\RingException' => $vendorDir . '/guzzlehttp/ringphp/src/Exception/RingException.php',
'GuzzleHttp\\Ring\\Future\\BaseFutureTrait' => $vendorDir . '/guzzlehttp/ringphp/src/Future/BaseFutureTrait.php',
'GuzzleHttp\\Ring\\Future\\CompletedFutureArray' => $vendorDir . '/guzzlehttp/ringphp/src/Future/CompletedFutureArray.php',
'GuzzleHttp\\Ring\\Future\\CompletedFutureValue' => $vendorDir . '/guzzlehttp/ringphp/src/Future/CompletedFutureValue.php',
'GuzzleHttp\\Ring\\Future\\FutureArray' => $vendorDir . '/guzzlehttp/ringphp/src/Future/FutureArray.php',
'GuzzleHttp\\Ring\\Future\\FutureArrayInterface' => $vendorDir . '/guzzlehttp/ringphp/src/Future/FutureArrayInterface.php',
'GuzzleHttp\\Ring\\Future\\FutureInterface' => $vendorDir . '/guzzlehttp/ringphp/src/Future/FutureInterface.php',
'GuzzleHttp\\Ring\\Future\\FutureValue' => $vendorDir . '/guzzlehttp/ringphp/src/Future/FutureValue.php',
'GuzzleHttp\\Ring\\Future\\MagicFutureTrait' => $vendorDir . '/guzzlehttp/ringphp/src/Future/MagicFutureTrait.php',
'GuzzleHttp\\Stream\\AppendStream' => $vendorDir . '/guzzlehttp/streams/src/AppendStream.php',
'GuzzleHttp\\Stream\\AsyncReadStream' => $vendorDir . '/guzzlehttp/streams/src/AsyncReadStream.php',
'GuzzleHttp\\Stream\\BufferStream' => $vendorDir . '/guzzlehttp/streams/src/BufferStream.php',
'GuzzleHttp\\Stream\\CachingStream' => $vendorDir . '/guzzlehttp/streams/src/CachingStream.php',
'GuzzleHttp\\Stream\\DroppingStream' => $vendorDir . '/guzzlehttp/streams/src/DroppingStream.php',
'GuzzleHttp\\Stream\\Exception\\CannotAttachException' => $vendorDir . '/guzzlehttp/streams/src/Exception/CannotAttachException.php',
'GuzzleHttp\\Stream\\Exception\\SeekException' => $vendorDir . '/guzzlehttp/streams/src/Exception/SeekException.php',
'GuzzleHttp\\Stream\\FnStream' => $vendorDir . '/guzzlehttp/streams/src/FnStream.php',
'GuzzleHttp\\Stream\\GuzzleStreamWrapper' => $vendorDir . '/guzzlehttp/streams/src/GuzzleStreamWrapper.php',
'GuzzleHttp\\Stream\\InflateStream' => $vendorDir . '/guzzlehttp/streams/src/InflateStream.php',
'GuzzleHttp\\Stream\\LazyOpenStream' => $vendorDir . '/guzzlehttp/streams/src/LazyOpenStream.php',
'GuzzleHttp\\Stream\\LimitStream' => $vendorDir . '/guzzlehttp/streams/src/LimitStream.php',
'GuzzleHttp\\Stream\\MetadataStreamInterface' => $vendorDir . '/guzzlehttp/streams/src/MetadataStreamInterface.php',
'GuzzleHttp\\Stream\\NoSeekStream' => $vendorDir . '/guzzlehttp/streams/src/NoSeekStream.php',
'GuzzleHttp\\Stream\\NullStream' => $vendorDir . '/guzzlehttp/streams/src/NullStream.php',
'GuzzleHttp\\Stream\\PumpStream' => $vendorDir . '/guzzlehttp/streams/src/PumpStream.php',
'GuzzleHttp\\Stream\\Stream' => $vendorDir . '/guzzlehttp/streams/src/Stream.php',
'GuzzleHttp\\Stream\\StreamDecoratorTrait' => $vendorDir . '/guzzlehttp/streams/src/StreamDecoratorTrait.php',
'GuzzleHttp\\Stream\\StreamInterface' => $vendorDir . '/guzzlehttp/streams/src/StreamInterface.php',
'GuzzleHttp\\Stream\\Utils' => $vendorDir . '/guzzlehttp/streams/src/Utils.php',
'GuzzleHttp\\Subscriber\\Cookie' => $vendorDir . '/guzzlehttp/guzzle/src/Subscriber/Cookie.php',
'GuzzleHttp\\Subscriber\\History' => $vendorDir . '/guzzlehttp/guzzle/src/Subscriber/History.php',
'GuzzleHttp\\Subscriber\\HttpError' => $vendorDir . '/guzzlehttp/guzzle/src/Subscriber/HttpError.php',
'GuzzleHttp\\Subscriber\\Mock' => $vendorDir . '/guzzlehttp/guzzle/src/Subscriber/Mock.php',
'GuzzleHttp\\Subscriber\\Prepare' => $vendorDir . '/guzzlehttp/guzzle/src/Subscriber/Prepare.php',
'GuzzleHttp\\Subscriber\\Redirect' => $vendorDir . '/guzzlehttp/guzzle/src/Subscriber/Redirect.php',
'GuzzleHttp\\ToArrayInterface' => $vendorDir . '/guzzlehttp/guzzle/src/ToArrayInterface.php',
'GuzzleHttp\\Transaction' => $vendorDir . '/guzzlehttp/guzzle/src/Transaction.php',
'GuzzleHttp\\UriTemplate' => $vendorDir . '/guzzlehttp/guzzle/src/UriTemplate.php',
'GuzzleHttp\\Url' => $vendorDir . '/guzzlehttp/guzzle/src/Url.php',
'GuzzleHttp\\Utils' => $vendorDir . '/guzzlehttp/guzzle/src/Utils.php',
'PrestaShop\\CircuitBreaker\\AdvancedCircuitBreaker' => $vendorDir . '/prestashop/circuit-breaker/src/AdvancedCircuitBreaker.php',
'PrestaShop\\CircuitBreaker\\AdvancedCircuitBreakerFactory' => $vendorDir . '/prestashop/circuit-breaker/src/AdvancedCircuitBreakerFactory.php',
'PrestaShop\\CircuitBreaker\\Client\\GuzzleClient' => $vendorDir . '/prestashop/circuit-breaker/src/Client/GuzzleClient.php',
'PrestaShop\\CircuitBreaker\\Contract\\CircuitBreakerInterface' => $vendorDir . '/prestashop/circuit-breaker/src/Contract/CircuitBreakerInterface.php',
'PrestaShop\\CircuitBreaker\\Contract\\ClientInterface' => $vendorDir . '/prestashop/circuit-breaker/src/Contract/ClientInterface.php',
'PrestaShop\\CircuitBreaker\\Contract\\FactoryInterface' => $vendorDir . '/prestashop/circuit-breaker/src/Contract/FactoryInterface.php',
'PrestaShop\\CircuitBreaker\\Contract\\FactorySettingsInterface' => $vendorDir . '/prestashop/circuit-breaker/src/Contract/FactorySettingsInterface.php',
'PrestaShop\\CircuitBreaker\\Contract\\PlaceInterface' => $vendorDir . '/prestashop/circuit-breaker/src/Contract/PlaceInterface.php',
'PrestaShop\\CircuitBreaker\\Contract\\StorageInterface' => $vendorDir . '/prestashop/circuit-breaker/src/Contract/StorageInterface.php',
'PrestaShop\\CircuitBreaker\\Contract\\SystemInterface' => $vendorDir . '/prestashop/circuit-breaker/src/Contract/SystemInterface.php',
'PrestaShop\\CircuitBreaker\\Contract\\TransactionInterface' => $vendorDir . '/prestashop/circuit-breaker/src/Contract/TransactionInterface.php',
'PrestaShop\\CircuitBreaker\\Contract\\TransitionDispatcherInterface' => $vendorDir . '/prestashop/circuit-breaker/src/Contract/TransitionDispatcherInterface.php',
'PrestaShop\\CircuitBreaker\\Event\\TransitionEvent' => $vendorDir . '/prestashop/circuit-breaker/src/Event/TransitionEvent.php',
'PrestaShop\\CircuitBreaker\\Exception\\CircuitBreakerException' => $vendorDir . '/prestashop/circuit-breaker/src/Exception/CircuitBreakerException.php',
'PrestaShop\\CircuitBreaker\\Exception\\InvalidPlaceException' => $vendorDir . '/prestashop/circuit-breaker/src/Exception/InvalidPlaceException.php',
'PrestaShop\\CircuitBreaker\\Exception\\InvalidTransactionException' => $vendorDir . '/prestashop/circuit-breaker/src/Exception/InvalidTransactionException.php',
'PrestaShop\\CircuitBreaker\\Exception\\TransactionNotFoundException' => $vendorDir . '/prestashop/circuit-breaker/src/Exception/TransactionNotFoundException.php',
'PrestaShop\\CircuitBreaker\\Exception\\UnavailableServiceException' => $vendorDir . '/prestashop/circuit-breaker/src/Exception/UnavailableServiceException.php',
'PrestaShop\\CircuitBreaker\\Exception\\UnsupportedMethodException' => $vendorDir . '/prestashop/circuit-breaker/src/Exception/UnsupportedMethodException.php',
'PrestaShop\\CircuitBreaker\\FactorySettings' => $vendorDir . '/prestashop/circuit-breaker/src/FactorySettings.php',
'PrestaShop\\CircuitBreaker\\PartialCircuitBreaker' => $vendorDir . '/prestashop/circuit-breaker/src/PartialCircuitBreaker.php',
'PrestaShop\\CircuitBreaker\\Place\\AbstractPlace' => $vendorDir . '/prestashop/circuit-breaker/src/Place/AbstractPlace.php',
'PrestaShop\\CircuitBreaker\\Place\\ClosedPlace' => $vendorDir . '/prestashop/circuit-breaker/src/Place/ClosedPlace.php',
'PrestaShop\\CircuitBreaker\\Place\\HalfOpenPlace' => $vendorDir . '/prestashop/circuit-breaker/src/Place/HalfOpenPlace.php',
'PrestaShop\\CircuitBreaker\\Place\\OpenPlace' => $vendorDir . '/prestashop/circuit-breaker/src/Place/OpenPlace.php',
'PrestaShop\\CircuitBreaker\\SimpleCircuitBreaker' => $vendorDir . '/prestashop/circuit-breaker/src/SimpleCircuitBreaker.php',
'PrestaShop\\CircuitBreaker\\SimpleCircuitBreakerFactory' => $vendorDir . '/prestashop/circuit-breaker/src/SimpleCircuitBreakerFactory.php',
'PrestaShop\\CircuitBreaker\\State' => $vendorDir . '/prestashop/circuit-breaker/src/State.php',
'PrestaShop\\CircuitBreaker\\Storage\\DoctrineCache' => $vendorDir . '/prestashop/circuit-breaker/src/Storage/DoctrineCache.php',
'PrestaShop\\CircuitBreaker\\Storage\\SimpleArray' => $vendorDir . '/prestashop/circuit-breaker/src/Storage/SimpleArray.php',
'PrestaShop\\CircuitBreaker\\Storage\\SymfonyCache' => $vendorDir . '/prestashop/circuit-breaker/src/Storage/SymfonyCache.php',
'PrestaShop\\CircuitBreaker\\SymfonyCircuitBreaker' => $vendorDir . '/prestashop/circuit-breaker/src/SymfonyCircuitBreaker.php',
'PrestaShop\\CircuitBreaker\\System\\MainSystem' => $vendorDir . '/prestashop/circuit-breaker/src/System/MainSystem.php',
'PrestaShop\\CircuitBreaker\\Transaction\\SimpleTransaction' => $vendorDir . '/prestashop/circuit-breaker/src/Transaction/SimpleTransaction.php',
'PrestaShop\\CircuitBreaker\\Transition' => $vendorDir . '/prestashop/circuit-breaker/src/Transition.php',
'PrestaShop\\CircuitBreaker\\Transition\\EventDispatcher' => $vendorDir . '/prestashop/circuit-breaker/src/Transition/EventDispatcher.php',
'PrestaShop\\CircuitBreaker\\Transition\\NullDispatcher' => $vendorDir . '/prestashop/circuit-breaker/src/Transition/NullDispatcher.php',
'PrestaShop\\CircuitBreaker\\Util\\Assert' => $vendorDir . '/prestashop/circuit-breaker/src/Util/Assert.php',
'PrestaShop\\CircuitBreaker\\Util\\ErrorFormatter' => $vendorDir . '/prestashop/circuit-breaker/src/Util/ErrorFormatter.php',
'PrestaShop\\Module\\Mbo\\AddonsSelectionLinkProvider' => $baseDir . '/src/AddonsSelectionLinkProvider.php',
'PrestaShop\\Module\\Mbo\\Controller\\Admin\\ModuleCatalogController' => $baseDir . '/src/Controller/Admin/ModuleCatalogController.php',
'PrestaShop\\Module\\Mbo\\Controller\\Admin\\ModuleRecommendedController' => $baseDir . '/src/Controller/Admin/ModuleRecommendedController.php',
'PrestaShop\\Module\\Mbo\\Controller\\Admin\\ModuleSelectionController' => $baseDir . '/src/Controller/Admin/ModuleSelectionController.php',
'PrestaShop\\Module\\Mbo\\Controller\\Admin\\ThemeCatalogController' => $baseDir . '/src/Controller/Admin/ThemeCatalogController.php',
'PrestaShop\\Module\\Mbo\\ExternalContentProvider\\ExternalContentProvider' => $baseDir . '/src/ExternalContentProvider/ExternalContentProvider.php',
'PrestaShop\\Module\\Mbo\\ExternalContentProvider\\ExternalContentProviderInterface' => $baseDir . '/src/ExternalContentProvider/ExternalContentProviderInterface.php',
'PrestaShop\\Module\\Mbo\\ModuleCollectionDataProvider' => $baseDir . '/src/ModuleCollectionDataProvider.php',
'PrestaShop\\Module\\Mbo\\RecommendedLink\\RecommendedLink' => $baseDir . '/src/RecommendedLink/RecommendedLink.php',
'PrestaShop\\Module\\Mbo\\RecommendedLink\\RecommendedLinkInterface' => $baseDir . '/src/RecommendedLink/RecommendedLinkInterface.php',
'PrestaShop\\Module\\Mbo\\RecommendedLink\\RecommendedLinkProvider' => $baseDir . '/src/RecommendedLink/RecommendedLinkProvider.php',
'PrestaShop\\Module\\Mbo\\RecommendedModule\\RecommendedModule' => $baseDir . '/src/RecommendedModule/RecommendedModule.php',
'PrestaShop\\Module\\Mbo\\RecommendedModule\\RecommendedModuleCollection' => $baseDir . '/src/RecommendedModule/RecommendedModuleCollection.php',
'PrestaShop\\Module\\Mbo\\RecommendedModule\\RecommendedModuleCollectionInterface' => $baseDir . '/src/RecommendedModule/RecommendedModuleCollectionInterface.php',
'PrestaShop\\Module\\Mbo\\RecommendedModule\\RecommendedModuleInterface' => $baseDir . '/src/RecommendedModule/RecommendedModuleInterface.php',
'PrestaShop\\Module\\Mbo\\RecommendedModule\\RecommendedModulePresenter' => $baseDir . '/src/RecommendedModule/RecommendedModulePresenter.php',
'PrestaShop\\Module\\Mbo\\RecommendedModule\\RecommendedModulePresenterInterface' => $baseDir . '/src/RecommendedModule/RecommendedModulePresenterInterface.php',
'PrestaShop\\Module\\Mbo\\Tab\\Tab' => $baseDir . '/src/Tab/Tab.php',
'PrestaShop\\Module\\Mbo\\Tab\\TabCollection' => $baseDir . '/src/Tab/TabCollection.php',
'PrestaShop\\Module\\Mbo\\Tab\\TabCollectionDecoderXml' => $baseDir . '/src/Tab/TabCollectionDecoderXml.php',
'PrestaShop\\Module\\Mbo\\Tab\\TabCollectionFactory' => $baseDir . '/src/Tab/TabCollectionFactory.php',
'PrestaShop\\Module\\Mbo\\Tab\\TabCollectionFactoryInterface' => $baseDir . '/src/Tab/TabCollectionFactoryInterface.php',
'PrestaShop\\Module\\Mbo\\Tab\\TabCollectionInterface' => $baseDir . '/src/Tab/TabCollectionInterface.php',
'PrestaShop\\Module\\Mbo\\Tab\\TabCollectionProvider' => $baseDir . '/src/Tab/TabCollectionProvider.php',
'PrestaShop\\Module\\Mbo\\Tab\\TabCollectionProviderInterface' => $baseDir . '/src/Tab/TabCollectionProviderInterface.php',
'PrestaShop\\Module\\Mbo\\Tab\\TabInterface' => $baseDir . '/src/Tab/TabInterface.php',
'React\\Promise\\CancellablePromiseInterface' => $vendorDir . '/react/promise/src/CancellablePromiseInterface.php',
'React\\Promise\\CancellationQueue' => $vendorDir . '/react/promise/src/CancellationQueue.php',
'React\\Promise\\Deferred' => $vendorDir . '/react/promise/src/Deferred.php',
'React\\Promise\\Exception\\LengthException' => $vendorDir . '/react/promise/src/Exception/LengthException.php',
'React\\Promise\\ExtendedPromiseInterface' => $vendorDir . '/react/promise/src/ExtendedPromiseInterface.php',
'React\\Promise\\FulfilledPromise' => $vendorDir . '/react/promise/src/FulfilledPromise.php',
'React\\Promise\\LazyPromise' => $vendorDir . '/react/promise/src/LazyPromise.php',
'React\\Promise\\Promise' => $vendorDir . '/react/promise/src/Promise.php',
'React\\Promise\\PromiseInterface' => $vendorDir . '/react/promise/src/PromiseInterface.php',
'React\\Promise\\PromisorInterface' => $vendorDir . '/react/promise/src/PromisorInterface.php',
'React\\Promise\\RejectedPromise' => $vendorDir . '/react/promise/src/RejectedPromise.php',
'React\\Promise\\UnhandledRejectionException' => $vendorDir . '/react/promise/src/UnhandledRejectionException.php',
'ps_mbo' => $baseDir . '/ps_mbo.php',
);

View File

@@ -0,0 +1,10 @@
<?php
// autoload_files.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'ad155f8f1cf0d418fe49e248db8c661b' => $vendorDir . '/react/promise/src/functions_include.php',
);

View File

@@ -0,0 +1,9 @@
<?php
// autoload_namespaces.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
);

View File

@@ -0,0 +1,15 @@
<?php
// autoload_psr4.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'React\\Promise\\' => array($vendorDir . '/react/promise/src'),
'PrestaShop\\Module\\Mbo\\' => array($baseDir . '/src'),
'PrestaShop\\CircuitBreaker\\' => array($vendorDir . '/prestashop/circuit-breaker/src'),
'GuzzleHttp\\Stream\\' => array($vendorDir . '/guzzlehttp/streams/src'),
'GuzzleHttp\\Ring\\' => array($vendorDir . '/guzzlehttp/ringphp/src'),
'GuzzleHttp\\' => array($vendorDir . '/guzzlehttp/guzzle/src'),
);

View File

@@ -0,0 +1,61 @@
<?php
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit3e44735d963ebd3a608c6dbc44a70076
{
private static $loader;
public static function loadClassLoader($class)
{
if ('Composer\Autoload\ClassLoader' === $class) {
require __DIR__ . '/ClassLoader.php';
}
}
public static function getLoader()
{
if (null !== self::$loader) {
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit3e44735d963ebd3a608c6dbc44a70076', 'loadClassLoader'), true, false);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInit3e44735d963ebd3a608c6dbc44a70076', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit3e44735d963ebd3a608c6dbc44a70076::getInitializer($loader));
} else {
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);
}
}
$loader->setClassMapAuthoritative(true);
$loader->register(false);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInit3e44735d963ebd3a608c6dbc44a70076::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire3e44735d963ebd3a608c6dbc44a70076($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequire3e44735d963ebd3a608c6dbc44a70076($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
}
}

View File

@@ -0,0 +1,259 @@
<?php
// autoload_static.php @generated by Composer
namespace Composer\Autoload;
class ComposerStaticInit3e44735d963ebd3a608c6dbc44a70076
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
);
public static $prefixLengthsPsr4 = array (
'R' =>
array (
'React\\Promise\\' => 14,
),
'P' =>
array (
'PrestaShop\\Module\\Mbo\\' => 22,
'PrestaShop\\CircuitBreaker\\' => 26,
),
'G' =>
array (
'GuzzleHttp\\Stream\\' => 18,
'GuzzleHttp\\Ring\\' => 16,
'GuzzleHttp\\' => 11,
),
);
public static $prefixDirsPsr4 = array (
'React\\Promise\\' =>
array (
0 => __DIR__ . '/..' . '/react/promise/src',
),
'PrestaShop\\Module\\Mbo\\' =>
array (
0 => __DIR__ . '/../..' . '/src',
),
'PrestaShop\\CircuitBreaker\\' =>
array (
0 => __DIR__ . '/..' . '/prestashop/circuit-breaker/src',
),
'GuzzleHttp\\Stream\\' =>
array (
0 => __DIR__ . '/..' . '/guzzlehttp/streams/src',
),
'GuzzleHttp\\Ring\\' =>
array (
0 => __DIR__ . '/..' . '/guzzlehttp/ringphp/src',
),
'GuzzleHttp\\' =>
array (
0 => __DIR__ . '/..' . '/guzzlehttp/guzzle/src',
),
);
public static $classMap = array (
'GuzzleHttp\\BatchResults' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/BatchResults.php',
'GuzzleHttp\\Client' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Client.php',
'GuzzleHttp\\ClientInterface' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/ClientInterface.php',
'GuzzleHttp\\Collection' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Collection.php',
'GuzzleHttp\\Cookie\\CookieJar' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Cookie/CookieJar.php',
'GuzzleHttp\\Cookie\\CookieJarInterface' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php',
'GuzzleHttp\\Cookie\\FileCookieJar' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php',
'GuzzleHttp\\Cookie\\SessionCookieJar' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php',
'GuzzleHttp\\Cookie\\SetCookie' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Cookie/SetCookie.php',
'GuzzleHttp\\Event\\AbstractEvent' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Event/AbstractEvent.php',
'GuzzleHttp\\Event\\AbstractRequestEvent' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Event/AbstractRequestEvent.php',
'GuzzleHttp\\Event\\AbstractRetryableEvent' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Event/AbstractRetryableEvent.php',
'GuzzleHttp\\Event\\AbstractTransferEvent' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Event/AbstractTransferEvent.php',
'GuzzleHttp\\Event\\BeforeEvent' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Event/BeforeEvent.php',
'GuzzleHttp\\Event\\CompleteEvent' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Event/CompleteEvent.php',
'GuzzleHttp\\Event\\Emitter' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Event/Emitter.php',
'GuzzleHttp\\Event\\EmitterInterface' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Event/EmitterInterface.php',
'GuzzleHttp\\Event\\EndEvent' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Event/EndEvent.php',
'GuzzleHttp\\Event\\ErrorEvent' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Event/ErrorEvent.php',
'GuzzleHttp\\Event\\EventInterface' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Event/EventInterface.php',
'GuzzleHttp\\Event\\HasEmitterInterface' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Event/HasEmitterInterface.php',
'GuzzleHttp\\Event\\HasEmitterTrait' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Event/HasEmitterTrait.php',
'GuzzleHttp\\Event\\ListenerAttacherTrait' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Event/ListenerAttacherTrait.php',
'GuzzleHttp\\Event\\ProgressEvent' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Event/ProgressEvent.php',
'GuzzleHttp\\Event\\RequestEvents' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Event/RequestEvents.php',
'GuzzleHttp\\Event\\SubscriberInterface' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Event/SubscriberInterface.php',
'GuzzleHttp\\Exception\\BadResponseException' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Exception/BadResponseException.php',
'GuzzleHttp\\Exception\\ClientException' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Exception/ClientException.php',
'GuzzleHttp\\Exception\\ConnectException' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Exception/ConnectException.php',
'GuzzleHttp\\Exception\\CouldNotRewindStreamException' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Exception/CouldNotRewindStreamException.php',
'GuzzleHttp\\Exception\\ParseException' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Exception/ParseException.php',
'GuzzleHttp\\Exception\\RequestException' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Exception/RequestException.php',
'GuzzleHttp\\Exception\\ServerException' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Exception/ServerException.php',
'GuzzleHttp\\Exception\\StateException' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Exception/StateException.php',
'GuzzleHttp\\Exception\\TooManyRedirectsException' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Exception/TooManyRedirectsException.php',
'GuzzleHttp\\Exception\\TransferException' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Exception/TransferException.php',
'GuzzleHttp\\Exception\\XmlParseException' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Exception/XmlParseException.php',
'GuzzleHttp\\HasDataTrait' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/HasDataTrait.php',
'GuzzleHttp\\Message\\AbstractMessage' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Message/AbstractMessage.php',
'GuzzleHttp\\Message\\AppliesHeadersInterface' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Message/AppliesHeadersInterface.php',
'GuzzleHttp\\Message\\FutureResponse' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Message/FutureResponse.php',
'GuzzleHttp\\Message\\MessageFactory' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Message/MessageFactory.php',
'GuzzleHttp\\Message\\MessageFactoryInterface' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Message/MessageFactoryInterface.php',
'GuzzleHttp\\Message\\MessageInterface' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Message/MessageInterface.php',
'GuzzleHttp\\Message\\MessageParser' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Message/MessageParser.php',
'GuzzleHttp\\Message\\Request' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Message/Request.php',
'GuzzleHttp\\Message\\RequestInterface' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Message/RequestInterface.php',
'GuzzleHttp\\Message\\Response' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Message/Response.php',
'GuzzleHttp\\Message\\ResponseInterface' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Message/ResponseInterface.php',
'GuzzleHttp\\Mimetypes' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Mimetypes.php',
'GuzzleHttp\\Pool' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Pool.php',
'GuzzleHttp\\Post\\MultipartBody' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Post/MultipartBody.php',
'GuzzleHttp\\Post\\PostBody' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Post/PostBody.php',
'GuzzleHttp\\Post\\PostBodyInterface' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Post/PostBodyInterface.php',
'GuzzleHttp\\Post\\PostFile' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Post/PostFile.php',
'GuzzleHttp\\Post\\PostFileInterface' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Post/PostFileInterface.php',
'GuzzleHttp\\Query' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Query.php',
'GuzzleHttp\\QueryParser' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/QueryParser.php',
'GuzzleHttp\\RequestFsm' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/RequestFsm.php',
'GuzzleHttp\\RingBridge' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/RingBridge.php',
'GuzzleHttp\\Ring\\Client\\ClientUtils' => __DIR__ . '/..' . '/guzzlehttp/ringphp/src/Client/ClientUtils.php',
'GuzzleHttp\\Ring\\Client\\CurlFactory' => __DIR__ . '/..' . '/guzzlehttp/ringphp/src/Client/CurlFactory.php',
'GuzzleHttp\\Ring\\Client\\CurlHandler' => __DIR__ . '/..' . '/guzzlehttp/ringphp/src/Client/CurlHandler.php',
'GuzzleHttp\\Ring\\Client\\CurlMultiHandler' => __DIR__ . '/..' . '/guzzlehttp/ringphp/src/Client/CurlMultiHandler.php',
'GuzzleHttp\\Ring\\Client\\Middleware' => __DIR__ . '/..' . '/guzzlehttp/ringphp/src/Client/Middleware.php',
'GuzzleHttp\\Ring\\Client\\MockHandler' => __DIR__ . '/..' . '/guzzlehttp/ringphp/src/Client/MockHandler.php',
'GuzzleHttp\\Ring\\Client\\StreamHandler' => __DIR__ . '/..' . '/guzzlehttp/ringphp/src/Client/StreamHandler.php',
'GuzzleHttp\\Ring\\Core' => __DIR__ . '/..' . '/guzzlehttp/ringphp/src/Core.php',
'GuzzleHttp\\Ring\\Exception\\CancelledException' => __DIR__ . '/..' . '/guzzlehttp/ringphp/src/Exception/CancelledException.php',
'GuzzleHttp\\Ring\\Exception\\CancelledFutureAccessException' => __DIR__ . '/..' . '/guzzlehttp/ringphp/src/Exception/CancelledFutureAccessException.php',
'GuzzleHttp\\Ring\\Exception\\ConnectException' => __DIR__ . '/..' . '/guzzlehttp/ringphp/src/Exception/ConnectException.php',
'GuzzleHttp\\Ring\\Exception\\RingException' => __DIR__ . '/..' . '/guzzlehttp/ringphp/src/Exception/RingException.php',
'GuzzleHttp\\Ring\\Future\\BaseFutureTrait' => __DIR__ . '/..' . '/guzzlehttp/ringphp/src/Future/BaseFutureTrait.php',
'GuzzleHttp\\Ring\\Future\\CompletedFutureArray' => __DIR__ . '/..' . '/guzzlehttp/ringphp/src/Future/CompletedFutureArray.php',
'GuzzleHttp\\Ring\\Future\\CompletedFutureValue' => __DIR__ . '/..' . '/guzzlehttp/ringphp/src/Future/CompletedFutureValue.php',
'GuzzleHttp\\Ring\\Future\\FutureArray' => __DIR__ . '/..' . '/guzzlehttp/ringphp/src/Future/FutureArray.php',
'GuzzleHttp\\Ring\\Future\\FutureArrayInterface' => __DIR__ . '/..' . '/guzzlehttp/ringphp/src/Future/FutureArrayInterface.php',
'GuzzleHttp\\Ring\\Future\\FutureInterface' => __DIR__ . '/..' . '/guzzlehttp/ringphp/src/Future/FutureInterface.php',
'GuzzleHttp\\Ring\\Future\\FutureValue' => __DIR__ . '/..' . '/guzzlehttp/ringphp/src/Future/FutureValue.php',
'GuzzleHttp\\Ring\\Future\\MagicFutureTrait' => __DIR__ . '/..' . '/guzzlehttp/ringphp/src/Future/MagicFutureTrait.php',
'GuzzleHttp\\Stream\\AppendStream' => __DIR__ . '/..' . '/guzzlehttp/streams/src/AppendStream.php',
'GuzzleHttp\\Stream\\AsyncReadStream' => __DIR__ . '/..' . '/guzzlehttp/streams/src/AsyncReadStream.php',
'GuzzleHttp\\Stream\\BufferStream' => __DIR__ . '/..' . '/guzzlehttp/streams/src/BufferStream.php',
'GuzzleHttp\\Stream\\CachingStream' => __DIR__ . '/..' . '/guzzlehttp/streams/src/CachingStream.php',
'GuzzleHttp\\Stream\\DroppingStream' => __DIR__ . '/..' . '/guzzlehttp/streams/src/DroppingStream.php',
'GuzzleHttp\\Stream\\Exception\\CannotAttachException' => __DIR__ . '/..' . '/guzzlehttp/streams/src/Exception/CannotAttachException.php',
'GuzzleHttp\\Stream\\Exception\\SeekException' => __DIR__ . '/..' . '/guzzlehttp/streams/src/Exception/SeekException.php',
'GuzzleHttp\\Stream\\FnStream' => __DIR__ . '/..' . '/guzzlehttp/streams/src/FnStream.php',
'GuzzleHttp\\Stream\\GuzzleStreamWrapper' => __DIR__ . '/..' . '/guzzlehttp/streams/src/GuzzleStreamWrapper.php',
'GuzzleHttp\\Stream\\InflateStream' => __DIR__ . '/..' . '/guzzlehttp/streams/src/InflateStream.php',
'GuzzleHttp\\Stream\\LazyOpenStream' => __DIR__ . '/..' . '/guzzlehttp/streams/src/LazyOpenStream.php',
'GuzzleHttp\\Stream\\LimitStream' => __DIR__ . '/..' . '/guzzlehttp/streams/src/LimitStream.php',
'GuzzleHttp\\Stream\\MetadataStreamInterface' => __DIR__ . '/..' . '/guzzlehttp/streams/src/MetadataStreamInterface.php',
'GuzzleHttp\\Stream\\NoSeekStream' => __DIR__ . '/..' . '/guzzlehttp/streams/src/NoSeekStream.php',
'GuzzleHttp\\Stream\\NullStream' => __DIR__ . '/..' . '/guzzlehttp/streams/src/NullStream.php',
'GuzzleHttp\\Stream\\PumpStream' => __DIR__ . '/..' . '/guzzlehttp/streams/src/PumpStream.php',
'GuzzleHttp\\Stream\\Stream' => __DIR__ . '/..' . '/guzzlehttp/streams/src/Stream.php',
'GuzzleHttp\\Stream\\StreamDecoratorTrait' => __DIR__ . '/..' . '/guzzlehttp/streams/src/StreamDecoratorTrait.php',
'GuzzleHttp\\Stream\\StreamInterface' => __DIR__ . '/..' . '/guzzlehttp/streams/src/StreamInterface.php',
'GuzzleHttp\\Stream\\Utils' => __DIR__ . '/..' . '/guzzlehttp/streams/src/Utils.php',
'GuzzleHttp\\Subscriber\\Cookie' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Subscriber/Cookie.php',
'GuzzleHttp\\Subscriber\\History' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Subscriber/History.php',
'GuzzleHttp\\Subscriber\\HttpError' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Subscriber/HttpError.php',
'GuzzleHttp\\Subscriber\\Mock' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Subscriber/Mock.php',
'GuzzleHttp\\Subscriber\\Prepare' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Subscriber/Prepare.php',
'GuzzleHttp\\Subscriber\\Redirect' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Subscriber/Redirect.php',
'GuzzleHttp\\ToArrayInterface' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/ToArrayInterface.php',
'GuzzleHttp\\Transaction' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Transaction.php',
'GuzzleHttp\\UriTemplate' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/UriTemplate.php',
'GuzzleHttp\\Url' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Url.php',
'GuzzleHttp\\Utils' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Utils.php',
'PrestaShop\\CircuitBreaker\\AdvancedCircuitBreaker' => __DIR__ . '/..' . '/prestashop/circuit-breaker/src/AdvancedCircuitBreaker.php',
'PrestaShop\\CircuitBreaker\\AdvancedCircuitBreakerFactory' => __DIR__ . '/..' . '/prestashop/circuit-breaker/src/AdvancedCircuitBreakerFactory.php',
'PrestaShop\\CircuitBreaker\\Client\\GuzzleClient' => __DIR__ . '/..' . '/prestashop/circuit-breaker/src/Client/GuzzleClient.php',
'PrestaShop\\CircuitBreaker\\Contract\\CircuitBreakerInterface' => __DIR__ . '/..' . '/prestashop/circuit-breaker/src/Contract/CircuitBreakerInterface.php',
'PrestaShop\\CircuitBreaker\\Contract\\ClientInterface' => __DIR__ . '/..' . '/prestashop/circuit-breaker/src/Contract/ClientInterface.php',
'PrestaShop\\CircuitBreaker\\Contract\\FactoryInterface' => __DIR__ . '/..' . '/prestashop/circuit-breaker/src/Contract/FactoryInterface.php',
'PrestaShop\\CircuitBreaker\\Contract\\FactorySettingsInterface' => __DIR__ . '/..' . '/prestashop/circuit-breaker/src/Contract/FactorySettingsInterface.php',
'PrestaShop\\CircuitBreaker\\Contract\\PlaceInterface' => __DIR__ . '/..' . '/prestashop/circuit-breaker/src/Contract/PlaceInterface.php',
'PrestaShop\\CircuitBreaker\\Contract\\StorageInterface' => __DIR__ . '/..' . '/prestashop/circuit-breaker/src/Contract/StorageInterface.php',
'PrestaShop\\CircuitBreaker\\Contract\\SystemInterface' => __DIR__ . '/..' . '/prestashop/circuit-breaker/src/Contract/SystemInterface.php',
'PrestaShop\\CircuitBreaker\\Contract\\TransactionInterface' => __DIR__ . '/..' . '/prestashop/circuit-breaker/src/Contract/TransactionInterface.php',
'PrestaShop\\CircuitBreaker\\Contract\\TransitionDispatcherInterface' => __DIR__ . '/..' . '/prestashop/circuit-breaker/src/Contract/TransitionDispatcherInterface.php',
'PrestaShop\\CircuitBreaker\\Event\\TransitionEvent' => __DIR__ . '/..' . '/prestashop/circuit-breaker/src/Event/TransitionEvent.php',
'PrestaShop\\CircuitBreaker\\Exception\\CircuitBreakerException' => __DIR__ . '/..' . '/prestashop/circuit-breaker/src/Exception/CircuitBreakerException.php',
'PrestaShop\\CircuitBreaker\\Exception\\InvalidPlaceException' => __DIR__ . '/..' . '/prestashop/circuit-breaker/src/Exception/InvalidPlaceException.php',
'PrestaShop\\CircuitBreaker\\Exception\\InvalidTransactionException' => __DIR__ . '/..' . '/prestashop/circuit-breaker/src/Exception/InvalidTransactionException.php',
'PrestaShop\\CircuitBreaker\\Exception\\TransactionNotFoundException' => __DIR__ . '/..' . '/prestashop/circuit-breaker/src/Exception/TransactionNotFoundException.php',
'PrestaShop\\CircuitBreaker\\Exception\\UnavailableServiceException' => __DIR__ . '/..' . '/prestashop/circuit-breaker/src/Exception/UnavailableServiceException.php',
'PrestaShop\\CircuitBreaker\\Exception\\UnsupportedMethodException' => __DIR__ . '/..' . '/prestashop/circuit-breaker/src/Exception/UnsupportedMethodException.php',
'PrestaShop\\CircuitBreaker\\FactorySettings' => __DIR__ . '/..' . '/prestashop/circuit-breaker/src/FactorySettings.php',
'PrestaShop\\CircuitBreaker\\PartialCircuitBreaker' => __DIR__ . '/..' . '/prestashop/circuit-breaker/src/PartialCircuitBreaker.php',
'PrestaShop\\CircuitBreaker\\Place\\AbstractPlace' => __DIR__ . '/..' . '/prestashop/circuit-breaker/src/Place/AbstractPlace.php',
'PrestaShop\\CircuitBreaker\\Place\\ClosedPlace' => __DIR__ . '/..' . '/prestashop/circuit-breaker/src/Place/ClosedPlace.php',
'PrestaShop\\CircuitBreaker\\Place\\HalfOpenPlace' => __DIR__ . '/..' . '/prestashop/circuit-breaker/src/Place/HalfOpenPlace.php',
'PrestaShop\\CircuitBreaker\\Place\\OpenPlace' => __DIR__ . '/..' . '/prestashop/circuit-breaker/src/Place/OpenPlace.php',
'PrestaShop\\CircuitBreaker\\SimpleCircuitBreaker' => __DIR__ . '/..' . '/prestashop/circuit-breaker/src/SimpleCircuitBreaker.php',
'PrestaShop\\CircuitBreaker\\SimpleCircuitBreakerFactory' => __DIR__ . '/..' . '/prestashop/circuit-breaker/src/SimpleCircuitBreakerFactory.php',
'PrestaShop\\CircuitBreaker\\State' => __DIR__ . '/..' . '/prestashop/circuit-breaker/src/State.php',
'PrestaShop\\CircuitBreaker\\Storage\\DoctrineCache' => __DIR__ . '/..' . '/prestashop/circuit-breaker/src/Storage/DoctrineCache.php',
'PrestaShop\\CircuitBreaker\\Storage\\SimpleArray' => __DIR__ . '/..' . '/prestashop/circuit-breaker/src/Storage/SimpleArray.php',
'PrestaShop\\CircuitBreaker\\Storage\\SymfonyCache' => __DIR__ . '/..' . '/prestashop/circuit-breaker/src/Storage/SymfonyCache.php',
'PrestaShop\\CircuitBreaker\\SymfonyCircuitBreaker' => __DIR__ . '/..' . '/prestashop/circuit-breaker/src/SymfonyCircuitBreaker.php',
'PrestaShop\\CircuitBreaker\\System\\MainSystem' => __DIR__ . '/..' . '/prestashop/circuit-breaker/src/System/MainSystem.php',
'PrestaShop\\CircuitBreaker\\Transaction\\SimpleTransaction' => __DIR__ . '/..' . '/prestashop/circuit-breaker/src/Transaction/SimpleTransaction.php',
'PrestaShop\\CircuitBreaker\\Transition' => __DIR__ . '/..' . '/prestashop/circuit-breaker/src/Transition.php',
'PrestaShop\\CircuitBreaker\\Transition\\EventDispatcher' => __DIR__ . '/..' . '/prestashop/circuit-breaker/src/Transition/EventDispatcher.php',
'PrestaShop\\CircuitBreaker\\Transition\\NullDispatcher' => __DIR__ . '/..' . '/prestashop/circuit-breaker/src/Transition/NullDispatcher.php',
'PrestaShop\\CircuitBreaker\\Util\\Assert' => __DIR__ . '/..' . '/prestashop/circuit-breaker/src/Util/Assert.php',
'PrestaShop\\CircuitBreaker\\Util\\ErrorFormatter' => __DIR__ . '/..' . '/prestashop/circuit-breaker/src/Util/ErrorFormatter.php',
'PrestaShop\\Module\\Mbo\\AddonsSelectionLinkProvider' => __DIR__ . '/../..' . '/src/AddonsSelectionLinkProvider.php',
'PrestaShop\\Module\\Mbo\\Controller\\Admin\\ModuleCatalogController' => __DIR__ . '/../..' . '/src/Controller/Admin/ModuleCatalogController.php',
'PrestaShop\\Module\\Mbo\\Controller\\Admin\\ModuleRecommendedController' => __DIR__ . '/../..' . '/src/Controller/Admin/ModuleRecommendedController.php',
'PrestaShop\\Module\\Mbo\\Controller\\Admin\\ModuleSelectionController' => __DIR__ . '/../..' . '/src/Controller/Admin/ModuleSelectionController.php',
'PrestaShop\\Module\\Mbo\\Controller\\Admin\\ThemeCatalogController' => __DIR__ . '/../..' . '/src/Controller/Admin/ThemeCatalogController.php',
'PrestaShop\\Module\\Mbo\\ExternalContentProvider\\ExternalContentProvider' => __DIR__ . '/../..' . '/src/ExternalContentProvider/ExternalContentProvider.php',
'PrestaShop\\Module\\Mbo\\ExternalContentProvider\\ExternalContentProviderInterface' => __DIR__ . '/../..' . '/src/ExternalContentProvider/ExternalContentProviderInterface.php',
'PrestaShop\\Module\\Mbo\\ModuleCollectionDataProvider' => __DIR__ . '/../..' . '/src/ModuleCollectionDataProvider.php',
'PrestaShop\\Module\\Mbo\\RecommendedLink\\RecommendedLink' => __DIR__ . '/../..' . '/src/RecommendedLink/RecommendedLink.php',
'PrestaShop\\Module\\Mbo\\RecommendedLink\\RecommendedLinkInterface' => __DIR__ . '/../..' . '/src/RecommendedLink/RecommendedLinkInterface.php',
'PrestaShop\\Module\\Mbo\\RecommendedLink\\RecommendedLinkProvider' => __DIR__ . '/../..' . '/src/RecommendedLink/RecommendedLinkProvider.php',
'PrestaShop\\Module\\Mbo\\RecommendedModule\\RecommendedModule' => __DIR__ . '/../..' . '/src/RecommendedModule/RecommendedModule.php',
'PrestaShop\\Module\\Mbo\\RecommendedModule\\RecommendedModuleCollection' => __DIR__ . '/../..' . '/src/RecommendedModule/RecommendedModuleCollection.php',
'PrestaShop\\Module\\Mbo\\RecommendedModule\\RecommendedModuleCollectionInterface' => __DIR__ . '/../..' . '/src/RecommendedModule/RecommendedModuleCollectionInterface.php',
'PrestaShop\\Module\\Mbo\\RecommendedModule\\RecommendedModuleInterface' => __DIR__ . '/../..' . '/src/RecommendedModule/RecommendedModuleInterface.php',
'PrestaShop\\Module\\Mbo\\RecommendedModule\\RecommendedModulePresenter' => __DIR__ . '/../..' . '/src/RecommendedModule/RecommendedModulePresenter.php',
'PrestaShop\\Module\\Mbo\\RecommendedModule\\RecommendedModulePresenterInterface' => __DIR__ . '/../..' . '/src/RecommendedModule/RecommendedModulePresenterInterface.php',
'PrestaShop\\Module\\Mbo\\Tab\\Tab' => __DIR__ . '/../..' . '/src/Tab/Tab.php',
'PrestaShop\\Module\\Mbo\\Tab\\TabCollection' => __DIR__ . '/../..' . '/src/Tab/TabCollection.php',
'PrestaShop\\Module\\Mbo\\Tab\\TabCollectionDecoderXml' => __DIR__ . '/../..' . '/src/Tab/TabCollectionDecoderXml.php',
'PrestaShop\\Module\\Mbo\\Tab\\TabCollectionFactory' => __DIR__ . '/../..' . '/src/Tab/TabCollectionFactory.php',
'PrestaShop\\Module\\Mbo\\Tab\\TabCollectionFactoryInterface' => __DIR__ . '/../..' . '/src/Tab/TabCollectionFactoryInterface.php',
'PrestaShop\\Module\\Mbo\\Tab\\TabCollectionInterface' => __DIR__ . '/../..' . '/src/Tab/TabCollectionInterface.php',
'PrestaShop\\Module\\Mbo\\Tab\\TabCollectionProvider' => __DIR__ . '/../..' . '/src/Tab/TabCollectionProvider.php',
'PrestaShop\\Module\\Mbo\\Tab\\TabCollectionProviderInterface' => __DIR__ . '/../..' . '/src/Tab/TabCollectionProviderInterface.php',
'PrestaShop\\Module\\Mbo\\Tab\\TabInterface' => __DIR__ . '/../..' . '/src/Tab/TabInterface.php',
'React\\Promise\\CancellablePromiseInterface' => __DIR__ . '/..' . '/react/promise/src/CancellablePromiseInterface.php',
'React\\Promise\\CancellationQueue' => __DIR__ . '/..' . '/react/promise/src/CancellationQueue.php',
'React\\Promise\\Deferred' => __DIR__ . '/..' . '/react/promise/src/Deferred.php',
'React\\Promise\\Exception\\LengthException' => __DIR__ . '/..' . '/react/promise/src/Exception/LengthException.php',
'React\\Promise\\ExtendedPromiseInterface' => __DIR__ . '/..' . '/react/promise/src/ExtendedPromiseInterface.php',
'React\\Promise\\FulfilledPromise' => __DIR__ . '/..' . '/react/promise/src/FulfilledPromise.php',
'React\\Promise\\LazyPromise' => __DIR__ . '/..' . '/react/promise/src/LazyPromise.php',
'React\\Promise\\Promise' => __DIR__ . '/..' . '/react/promise/src/Promise.php',
'React\\Promise\\PromiseInterface' => __DIR__ . '/..' . '/react/promise/src/PromiseInterface.php',
'React\\Promise\\PromisorInterface' => __DIR__ . '/..' . '/react/promise/src/PromisorInterface.php',
'React\\Promise\\RejectedPromise' => __DIR__ . '/..' . '/react/promise/src/RejectedPromise.php',
'React\\Promise\\UnhandledRejectionException' => __DIR__ . '/..' . '/react/promise/src/UnhandledRejectionException.php',
'ps_mbo' => __DIR__ . '/../..' . '/ps_mbo.php',
);
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit3e44735d963ebd3a608c6dbc44a70076::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit3e44735d963ebd3a608c6dbc44a70076::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit3e44735d963ebd3a608c6dbc44a70076::$classMap;
}, null, ClassLoader::class);
}
}

View File

@@ -0,0 +1,270 @@
[
{
"name": "guzzlehttp/guzzle",
"version": "5.3.4",
"version_normalized": "5.3.4.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/guzzle.git",
"reference": "b87eda7a7162f95574032da17e9323c9899cb6b2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/b87eda7a7162f95574032da17e9323c9899cb6b2",
"reference": "b87eda7a7162f95574032da17e9323c9899cb6b2",
"shasum": ""
},
"require": {
"guzzlehttp/ringphp": "^1.1",
"php": ">=5.4.0",
"react/promise": "^2.2"
},
"require-dev": {
"ext-curl": "*",
"phpunit/phpunit": "^4.0"
},
"time": "2019-10-30T09:32:00+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"GuzzleHttp\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
}
],
"description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients",
"homepage": "http://guzzlephp.org/",
"keywords": [
"client",
"curl",
"framework",
"http",
"http client",
"rest",
"web service"
]
},
{
"name": "guzzlehttp/ringphp",
"version": "1.1.1",
"version_normalized": "1.1.1.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/RingPHP.git",
"reference": "5e2a174052995663dd68e6b5ad838afd47dd615b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/RingPHP/zipball/5e2a174052995663dd68e6b5ad838afd47dd615b",
"reference": "5e2a174052995663dd68e6b5ad838afd47dd615b",
"shasum": ""
},
"require": {
"guzzlehttp/streams": "~3.0",
"php": ">=5.4.0",
"react/promise": "~2.0"
},
"require-dev": {
"ext-curl": "*",
"phpunit/phpunit": "~4.0"
},
"suggest": {
"ext-curl": "Guzzle will use specific adapters if cURL is present"
},
"time": "2018-07-31T13:22:33+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.1-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"GuzzleHttp\\Ring\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
}
],
"description": "Provides a simple API and specification that abstracts away the details of HTTP into a single PHP function.",
"abandoned": true
},
{
"name": "guzzlehttp/streams",
"version": "3.0.0",
"version_normalized": "3.0.0.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/streams.git",
"reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/streams/zipball/47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5",
"reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5",
"shasum": ""
},
"require": {
"php": ">=5.4.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
},
"time": "2014-10-12T19:18:40+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"GuzzleHttp\\Stream\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
}
],
"description": "Provides a simple abstraction over streams of data",
"homepage": "http://guzzlephp.org/",
"keywords": [
"Guzzle",
"stream"
],
"abandoned": true
},
{
"name": "prestashop/circuit-breaker",
"version": "v3.0.0",
"version_normalized": "3.0.0.0",
"source": {
"type": "git",
"url": "https://github.com/PrestaShop/circuit-breaker.git",
"reference": "8764540d470b533c9484534343688733bc363f77"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PrestaShop/circuit-breaker/zipball/8764540d470b533c9484534343688733bc363f77",
"reference": "8764540d470b533c9484534343688733bc363f77",
"shasum": ""
},
"require": {
"guzzlehttp/guzzle": "^5",
"php": ">=5.6"
},
"require-dev": {
"doctrine/cache": "^1.6.0",
"friendsofphp/php-cs-fixer": "^2.12",
"phpunit/phpunit": "^5.7.0",
"squizlabs/php_codesniffer": "3.*",
"symfony/cache": "^3.4.0",
"symfony/event-dispatcher": "^3.4",
"vimeo/psalm": "^1.1"
},
"suggest": {
"doctrine/cache": "Allows use of Doctrine Cache adapters to store transactions",
"ext-apcu": "Allows use of APCu adapter (performant) to store transactions",
"guzzlehttp/cache-subscriber": "Allow use of Guzzle cache (use dev-master for most recent changes)",
"symfony/cache": "Allows use of Symfony Cache adapters to store transactions"
},
"time": "2019-06-13T10:50:14+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"PrestaShop\\CircuitBreaker\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PrestaShop SA",
"email": "contact@prestashop.com"
},
{
"name": "PrestaShop Community",
"homepage": "http://contributors.prestashop.com/"
}
],
"description": "A circuit breaker implementation for PHP"
},
{
"name": "react/promise",
"version": "v2.7.1",
"version_normalized": "2.7.1.0",
"source": {
"type": "git",
"url": "https://github.com/reactphp/promise.git",
"reference": "31ffa96f8d2ed0341a57848cbb84d88b89dd664d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/reactphp/promise/zipball/31ffa96f8d2ed0341a57848cbb84d88b89dd664d",
"reference": "31ffa96f8d2ed0341a57848cbb84d88b89dd664d",
"shasum": ""
},
"require": {
"php": ">=5.4.0"
},
"require-dev": {
"phpunit/phpunit": "~4.8"
},
"time": "2019-01-07T21:25:54+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"React\\Promise\\": "src/"
},
"files": [
"src/functions_include.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jan Sorgalla",
"email": "jsorgalla@gmail.com"
}
],
"description": "A lightweight implementation of CommonJS Promises/A for PHP",
"keywords": [
"promise",
"promises"
]
}
]

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,19 @@
Copyright (c) 2011-2015 Michael Dowling, https://github.com/mtdowling <mtdowling@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,70 @@
Guzzle, PHP HTTP client and webservice framework
================================================
[![Build Status](https://secure.travis-ci.org/guzzle/guzzle.svg?branch=master)](http://travis-ci.org/guzzle/guzzle)
Guzzle is a PHP HTTP client that makes it easy to send HTTP requests and
trivial to integrate with web services.
- Manages things like persistent connections, represents query strings as
collections, simplifies sending streaming POST requests with fields and
files, and abstracts away the underlying HTTP transport layer.
- Can send both synchronous and asynchronous requests using the same interface
without requiring a dependency on a specific event loop.
- Pluggable HTTP adapters allows Guzzle to integrate with any method you choose
for sending HTTP requests over the wire (e.g., cURL, sockets, PHP's stream
wrapper, non-blocking event loops like ReactPHP.
- Guzzle makes it so that you no longer need to fool around with cURL options,
stream contexts, or sockets.
```php
$client = new GuzzleHttp\Client();
$response = $client->get('http://guzzlephp.org');
$res = $client->get('https://api.github.com/user', ['auth' => ['user', 'pass']]);
echo $res->getStatusCode();
// "200"
echo $res->getHeader('content-type');
// 'application/json; charset=utf8'
echo $res->getBody();
// {"type":"User"...'
var_export($res->json());
// Outputs the JSON decoded data
// Send an asynchronous request.
$req = $client->createRequest('GET', 'http://httpbin.org', ['future' => true]);
$client->send($req)->then(function ($response) {
echo 'I completed! ' . $response;
});
```
Get more information and answers with the
[Documentation](http://guzzlephp.org/),
[Forums](https://groups.google.com/forum/?hl=en#!forum/guzzle),
and [Gitter](https://gitter.im/guzzle/guzzle).
### Installing via Composer
The recommended way to install Guzzle is through
[Composer](http://getcomposer.org).
```bash
# Install Composer
curl -sS https://getcomposer.org/installer | php
```
Next, run the Composer command to install the latest stable version of Guzzle:
```bash
composer.phar require guzzlehttp/guzzle
```
After installing, you need to require Composer's autoloader:
```php
require 'vendor/autoload.php';
```
### Documentation
More information can be found in the online documentation at
http://guzzlephp.org/.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,38 @@
{
"name": "guzzlehttp/guzzle",
"type": "library",
"description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients",
"keywords": ["framework", "http", "rest", "web service", "curl", "client", "HTTP client"],
"homepage": "http://guzzlephp.org/",
"license": "MIT",
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
}
],
"require": {
"php": ">=5.4.0",
"guzzlehttp/ringphp": "^1.1",
"react/promise": "^2.2"
},
"require-dev": {
"ext-curl": "*",
"phpunit/phpunit": "^4.0"
},
"autoload": {
"psr-4": {
"GuzzleHttp\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"GuzzleHttp\\Tests\\": "tests/"
}
},
"scripts": {
"test": "make test",
"test-ci": "make coverage"
}
}

View File

@@ -0,0 +1,148 @@
<?php
namespace GuzzleHttp;
/**
* Represents the result of a batch operation. This result container is
* iterable, countable, and you can can get a result by value using the
* getResult function.
*
* Successful results are anything other than exceptions. Failure results are
* exceptions.
*
* @package GuzzleHttp
*/
class BatchResults implements \Countable, \IteratorAggregate, \ArrayAccess
{
private $hash;
/**
* @param \SplObjectStorage $hash Hash of key objects to result values.
*/
public function __construct(\SplObjectStorage $hash)
{
$this->hash = $hash;
}
/**
* Get the keys that are available on the batch result.
*
* @return array
*/
public function getKeys()
{
return iterator_to_array($this->hash);
}
/**
* Gets a result from the container for the given object. When getting
* results for a batch of requests, provide the request object.
*
* @param object $forObject Object to retrieve the result for.
*
* @return mixed|null
*/
public function getResult($forObject)
{
return isset($this->hash[$forObject]) ? $this->hash[$forObject] : null;
}
/**
* Get an array of successful results.
*
* @return array
*/
public function getSuccessful()
{
$results = [];
foreach ($this->hash as $key) {
if (!($this->hash[$key] instanceof \Exception)) {
$results[] = $this->hash[$key];
}
}
return $results;
}
/**
* Get an array of failed results.
*
* @return array
*/
public function getFailures()
{
$results = [];
foreach ($this->hash as $key) {
if ($this->hash[$key] instanceof \Exception) {
$results[] = $this->hash[$key];
}
}
return $results;
}
/**
* Allows iteration over all batch result values.
*
* @return \ArrayIterator
*/
public function getIterator()
{
$results = [];
foreach ($this->hash as $key) {
$results[] = $this->hash[$key];
}
return new \ArrayIterator($results);
}
/**
* Counts the number of elements in the batch result.
*
* @return int
*/
public function count()
{
return count($this->hash);
}
/**
* Checks if the batch contains a specific numerical array index.
*
* @param int $key Index to access
*
* @return bool
*/
public function offsetExists($key)
{
return $key < count($this->hash);
}
/**
* Allows access of the batch using a numerical array index.
*
* @param int $key Index to access.
*
* @return mixed|null
*/
public function offsetGet($key)
{
$i = -1;
foreach ($this->hash as $obj) {
if ($key === ++$i) {
return $this->hash[$obj];
}
}
return null;
}
public function offsetUnset($key)
{
throw new \RuntimeException('Not implemented');
}
public function offsetSet($key, $value)
{
throw new \RuntimeException('Not implemented');
}
}

View File

@@ -0,0 +1,362 @@
<?php
namespace GuzzleHttp;
use GuzzleHttp\Event\HasEmitterTrait;
use GuzzleHttp\Message\MessageFactory;
use GuzzleHttp\Message\MessageFactoryInterface;
use GuzzleHttp\Message\RequestInterface;
use GuzzleHttp\Message\FutureResponse;
use GuzzleHttp\Ring\Core;
use GuzzleHttp\Ring\Future\FutureInterface;
use GuzzleHttp\Exception\RequestException;
use React\Promise\FulfilledPromise;
use React\Promise\RejectedPromise;
/**
* HTTP client
*/
class Client implements ClientInterface
{
use HasEmitterTrait;
/** @var MessageFactoryInterface Request factory used by the client */
private $messageFactory;
/** @var Url Base URL of the client */
private $baseUrl;
/** @var array Default request options */
private $defaults;
/** @var callable Request state machine */
private $fsm;
/**
* Clients accept an array of constructor parameters.
*
* Here's an example of creating a client using an URI template for the
* client's base_url and an array of default request options to apply
* to each request:
*
* $client = new Client([
* 'base_url' => [
* 'http://www.foo.com/{version}/',
* ['version' => '123']
* ],
* 'defaults' => [
* 'timeout' => 10,
* 'allow_redirects' => false,
* 'proxy' => '192.168.16.1:10'
* ]
* ]);
*
* @param array $config Client configuration settings
* - base_url: Base URL of the client that is merged into relative URLs.
* Can be a string or an array that contains a URI template followed
* by an associative array of expansion variables to inject into the
* URI template.
* - handler: callable RingPHP handler used to transfer requests
* - message_factory: Factory used to create request and response object
* - defaults: Default request options to apply to each request
* - emitter: Event emitter used for request events
* - fsm: (internal use only) The request finite state machine. A
* function that accepts a transaction and optional final state. The
* function is responsible for transitioning a request through its
* lifecycle events.
*/
public function __construct(array $config = [])
{
$this->configureBaseUrl($config);
$this->configureDefaults($config);
if (isset($config['emitter'])) {
$this->emitter = $config['emitter'];
}
$this->messageFactory = isset($config['message_factory'])
? $config['message_factory']
: new MessageFactory();
if (isset($config['fsm'])) {
$this->fsm = $config['fsm'];
} else {
if (isset($config['handler'])) {
$handler = $config['handler'];
} elseif (isset($config['adapter'])) {
$handler = $config['adapter'];
} else {
$handler = Utils::getDefaultHandler();
}
$this->fsm = new RequestFsm($handler, $this->messageFactory);
}
}
public function getDefaultOption($keyOrPath = null)
{
return $keyOrPath === null
? $this->defaults
: Utils::getPath($this->defaults, $keyOrPath);
}
public function setDefaultOption($keyOrPath, $value)
{
Utils::setPath($this->defaults, $keyOrPath, $value);
}
public function getBaseUrl()
{
return (string) $this->baseUrl;
}
public function createRequest($method, $url = null, array $options = [])
{
$options = $this->mergeDefaults($options);
// Use a clone of the client's emitter
$options['config']['emitter'] = clone $this->getEmitter();
$url = $url || (is_string($url) && strlen($url))
? $this->buildUrl($url)
: (string) $this->baseUrl;
return $this->messageFactory->createRequest($method, $url, $options);
}
public function get($url = null, $options = [])
{
return $this->send($this->createRequest('GET', $url, $options));
}
public function head($url = null, array $options = [])
{
return $this->send($this->createRequest('HEAD', $url, $options));
}
public function delete($url = null, array $options = [])
{
return $this->send($this->createRequest('DELETE', $url, $options));
}
public function put($url = null, array $options = [])
{
return $this->send($this->createRequest('PUT', $url, $options));
}
public function patch($url = null, array $options = [])
{
return $this->send($this->createRequest('PATCH', $url, $options));
}
public function post($url = null, array $options = [])
{
return $this->send($this->createRequest('POST', $url, $options));
}
public function options($url = null, array $options = [])
{
return $this->send($this->createRequest('OPTIONS', $url, $options));
}
public function send(RequestInterface $request)
{
$isFuture = $request->getConfig()->get('future');
$trans = new Transaction($this, $request, $isFuture);
$fn = $this->fsm;
try {
$fn($trans);
if ($isFuture) {
// Turn the normal response into a future if needed.
return $trans->response instanceof FutureInterface
? $trans->response
: new FutureResponse(new FulfilledPromise($trans->response));
}
// Resolve deep futures if this is not a future
// transaction. This accounts for things like retries
// that do not have an immediate side-effect.
while ($trans->response instanceof FutureInterface) {
$trans->response = $trans->response->wait();
}
return $trans->response;
} catch (\Exception $e) {
if ($isFuture) {
// Wrap the exception in a promise
return new FutureResponse(new RejectedPromise($e));
}
throw RequestException::wrapException($trans->request, $e);
} catch (\TypeError $error) {
$exception = new \Exception($error->getMessage(), $error->getCode(), $error);
if ($isFuture) {
// Wrap the exception in a promise
return new FutureResponse(new RejectedPromise($exception));
}
throw RequestException::wrapException($trans->request, $exception);
}
}
/**
* Get an array of default options to apply to the client
*
* @return array
*/
protected function getDefaultOptions()
{
$settings = [
'allow_redirects' => true,
'exceptions' => true,
'decode_content' => true,
'verify' => true
];
// Use the standard Linux HTTP_PROXY and HTTPS_PROXY if set.
// We can only trust the HTTP_PROXY environment variable in a CLI
// process due to the fact that PHP has no reliable mechanism to
// get environment variables that start with "HTTP_".
if (php_sapi_name() == 'cli' && getenv('HTTP_PROXY')) {
$settings['proxy']['http'] = getenv('HTTP_PROXY');
}
if ($proxy = getenv('HTTPS_PROXY')) {
$settings['proxy']['https'] = $proxy;
}
return $settings;
}
/**
* Expand a URI template and inherit from the base URL if it's relative
*
* @param string|array $url URL or an array of the URI template to expand
* followed by a hash of template varnames.
* @return string
* @throws \InvalidArgumentException
*/
private function buildUrl($url)
{
// URI template (absolute or relative)
if (!is_array($url)) {
return strpos($url, '://')
? (string) $url
: (string) $this->baseUrl->combine($url);
}
if (!isset($url[1])) {
throw new \InvalidArgumentException('You must provide a hash of '
. 'varname options in the second element of a URL array.');
}
// Absolute URL
if (strpos($url[0], '://')) {
return Utils::uriTemplate($url[0], $url[1]);
}
// Combine the relative URL with the base URL
return (string) $this->baseUrl->combine(
Utils::uriTemplate($url[0], $url[1])
);
}
private function configureBaseUrl(&$config)
{
if (!isset($config['base_url'])) {
$this->baseUrl = new Url('', '');
} elseif (!is_array($config['base_url'])) {
$this->baseUrl = Url::fromString($config['base_url']);
} elseif (count($config['base_url']) < 2) {
throw new \InvalidArgumentException('You must provide a hash of '
. 'varname options in the second element of a base_url array.');
} else {
$this->baseUrl = Url::fromString(
Utils::uriTemplate(
$config['base_url'][0],
$config['base_url'][1]
)
);
$config['base_url'] = (string) $this->baseUrl;
}
}
private function configureDefaults($config)
{
if (!isset($config['defaults'])) {
$this->defaults = $this->getDefaultOptions();
} else {
$this->defaults = array_replace(
$this->getDefaultOptions(),
$config['defaults']
);
}
// Add the default user-agent header
if (!isset($this->defaults['headers'])) {
$this->defaults['headers'] = [
'User-Agent' => Utils::getDefaultUserAgent()
];
} elseif (!Core::hasHeader($this->defaults, 'User-Agent')) {
// Add the User-Agent header if one was not already set
$this->defaults['headers']['User-Agent'] = Utils::getDefaultUserAgent();
}
}
/**
* Merges default options into the array passed by reference.
*
* @param array $options Options to modify by reference
*
* @return array
*/
private function mergeDefaults($options)
{
$defaults = $this->defaults;
// Case-insensitively merge in default headers if both defaults and
// options have headers specified.
if (!empty($defaults['headers']) && !empty($options['headers'])) {
// Create a set of lowercased keys that are present.
$lkeys = [];
foreach (array_keys($options['headers']) as $k) {
$lkeys[strtolower($k)] = true;
}
// Merge in lowercase default keys when not present in above set.
foreach ($defaults['headers'] as $key => $value) {
if (!isset($lkeys[strtolower($key)])) {
$options['headers'][$key] = $value;
}
}
// No longer need to merge in headers.
unset($defaults['headers']);
}
$result = array_replace_recursive($defaults, $options);
foreach ($options as $k => $v) {
if ($v === null) {
unset($result[$k]);
}
}
return $result;
}
/**
* @deprecated Use {@see GuzzleHttp\Pool} instead.
* @see GuzzleHttp\Pool
*/
public function sendAll($requests, array $options = [])
{
Pool::send($this, $requests, $options);
}
/**
* @deprecated Use GuzzleHttp\Utils::getDefaultHandler
*/
public static function getDefaultHandler()
{
return Utils::getDefaultHandler();
}
/**
* @deprecated Use GuzzleHttp\Utils::getDefaultUserAgent
*/
public static function getDefaultUserAgent()
{
return Utils::getDefaultUserAgent();
}
}

View File

@@ -0,0 +1,150 @@
<?php
namespace GuzzleHttp;
use GuzzleHttp\Event\HasEmitterInterface;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Message\RequestInterface;
use GuzzleHttp\Message\ResponseInterface;
/**
* Client interface for sending HTTP requests
*/
interface ClientInterface extends HasEmitterInterface
{
const VERSION = '5.3.1';
/**
* Create and return a new {@see RequestInterface} object.
*
* Use an absolute path to override the base path of the client, or a
* relative path to append to the base path of the client. The URL can
* contain the query string as well. Use an array to provide a URL
* template and additional variables to use in the URL template expansion.
*
* @param string $method HTTP method
* @param string|array|Url $url URL or URI template
* @param array $options Array of request options to apply.
*
* @return RequestInterface
*/
public function createRequest($method, $url = null, array $options = []);
/**
* Send a GET request
*
* @param string|array|Url $url URL or URI template
* @param array $options Array of request options to apply.
*
* @return ResponseInterface
* @throws RequestException When an error is encountered
*/
public function get($url = null, $options = []);
/**
* Send a HEAD request
*
* @param string|array|Url $url URL or URI template
* @param array $options Array of request options to apply.
*
* @return ResponseInterface
* @throws RequestException When an error is encountered
*/
public function head($url = null, array $options = []);
/**
* Send a DELETE request
*
* @param string|array|Url $url URL or URI template
* @param array $options Array of request options to apply.
*
* @return ResponseInterface
* @throws RequestException When an error is encountered
*/
public function delete($url = null, array $options = []);
/**
* Send a PUT request
*
* @param string|array|Url $url URL or URI template
* @param array $options Array of request options to apply.
*
* @return ResponseInterface
* @throws RequestException When an error is encountered
*/
public function put($url = null, array $options = []);
/**
* Send a PATCH request
*
* @param string|array|Url $url URL or URI template
* @param array $options Array of request options to apply.
*
* @return ResponseInterface
* @throws RequestException When an error is encountered
*/
public function patch($url = null, array $options = []);
/**
* Send a POST request
*
* @param string|array|Url $url URL or URI template
* @param array $options Array of request options to apply.
*
* @return ResponseInterface
* @throws RequestException When an error is encountered
*/
public function post($url = null, array $options = []);
/**
* Send an OPTIONS request
*
* @param string|array|Url $url URL or URI template
* @param array $options Array of request options to apply.
*
* @return ResponseInterface
* @throws RequestException When an error is encountered
*/
public function options($url = null, array $options = []);
/**
* Sends a single request
*
* @param RequestInterface $request Request to send
*
* @return \GuzzleHttp\Message\ResponseInterface
* @throws \LogicException When the handler does not populate a response
* @throws RequestException When an error is encountered
*/
public function send(RequestInterface $request);
/**
* Get default request options of the client.
*
* @param string|null $keyOrPath The Path to a particular default request
* option to retrieve or pass null to retrieve all default request
* options. The syntax uses "/" to denote a path through nested PHP
* arrays. For example, "headers/content-type".
*
* @return mixed
*/
public function getDefaultOption($keyOrPath = null);
/**
* Set a default request option on the client so that any request created
* by the client will use the provided default value unless overridden
* explicitly when creating a request.
*
* @param string|null $keyOrPath The Path to a particular configuration
* value to set. The syntax uses a path notation that allows you to
* specify nested configuration values (e.g., 'headers/content-type').
* @param mixed $value Default request option value to set
*/
public function setDefaultOption($keyOrPath, $value);
/**
* Get the base URL of the client.
*
* @return string Returns the base URL if present
*/
public function getBaseUrl();
}

View File

@@ -0,0 +1,236 @@
<?php
namespace GuzzleHttp;
/**
* Key value pair collection object
*/
class Collection implements
\ArrayAccess,
\IteratorAggregate,
\Countable,
ToArrayInterface
{
use HasDataTrait;
/**
* @param array $data Associative array of data to set
*/
public function __construct(array $data = [])
{
$this->data = $data;
}
/**
* Create a new collection from an array, validate the keys, and add default
* values where missing
*
* @param array $config Configuration values to apply.
* @param array $defaults Default parameters
* @param array $required Required parameter names
*
* @return self
* @throws \InvalidArgumentException if a parameter is missing
*/
public static function fromConfig(
array $config = [],
array $defaults = [],
array $required = []
) {
$data = $config + $defaults;
if ($missing = array_diff($required, array_keys($data))) {
throw new \InvalidArgumentException(
'Config is missing the following keys: ' .
implode(', ', $missing));
}
return new self($data);
}
/**
* Removes all key value pairs
*/
public function clear()
{
$this->data = [];
}
/**
* Get a specific key value.
*
* @param string $key Key to retrieve.
*
* @return mixed|null Value of the key or NULL
*/
public function get($key)
{
return isset($this->data[$key]) ? $this->data[$key] : null;
}
/**
* Set a key value pair
*
* @param string $key Key to set
* @param mixed $value Value to set
*/
public function set($key, $value)
{
$this->data[$key] = $value;
}
/**
* Add a value to a key. If a key of the same name has already been added,
* the key value will be converted into an array and the new value will be
* pushed to the end of the array.
*
* @param string $key Key to add
* @param mixed $value Value to add to the key
*/
public function add($key, $value)
{
if (!array_key_exists($key, $this->data)) {
$this->data[$key] = $value;
} elseif (is_array($this->data[$key])) {
$this->data[$key][] = $value;
} else {
$this->data[$key] = array($this->data[$key], $value);
}
}
/**
* Remove a specific key value pair
*
* @param string $key A key to remove
*/
public function remove($key)
{
unset($this->data[$key]);
}
/**
* Get all keys in the collection
*
* @return array
*/
public function getKeys()
{
return array_keys($this->data);
}
/**
* Returns whether or not the specified key is present.
*
* @param string $key The key for which to check the existence.
*
* @return bool
*/
public function hasKey($key)
{
return array_key_exists($key, $this->data);
}
/**
* Checks if any keys contains a certain value
*
* @param string $value Value to search for
*
* @return mixed Returns the key if the value was found FALSE if the value
* was not found.
*/
public function hasValue($value)
{
return array_search($value, $this->data, true);
}
/**
* Replace the data of the object with the value of an array
*
* @param array $data Associative array of data
*/
public function replace(array $data)
{
$this->data = $data;
}
/**
* Add and merge in a Collection or array of key value pair data.
*
* @param Collection|array $data Associative array of key value pair data
*/
public function merge($data)
{
foreach ($data as $key => $value) {
$this->add($key, $value);
}
}
/**
* Overwrite key value pairs in this collection with all of the data from
* an array or collection.
*
* @param array|\Traversable $data Values to override over this config
*/
public function overwriteWith($data)
{
if (is_array($data)) {
$this->data = $data + $this->data;
} elseif ($data instanceof Collection) {
$this->data = $data->toArray() + $this->data;
} else {
foreach ($data as $key => $value) {
$this->data[$key] = $value;
}
}
}
/**
* Returns a Collection containing all the elements of the collection after
* applying the callback function to each one.
*
* The callable should accept three arguments:
* - (string) $key
* - (string) $value
* - (array) $context
*
* The callable must return a the altered or unaltered value.
*
* @param callable $closure Map function to apply
* @param array $context Context to pass to the callable
*
* @return Collection
*/
public function map(callable $closure, array $context = [])
{
$collection = new static();
foreach ($this as $key => $value) {
$collection[$key] = $closure($key, $value, $context);
}
return $collection;
}
/**
* Iterates over each key value pair in the collection passing them to the
* callable. If the callable returns true, the current value from input is
* returned into the result Collection.
*
* The callable must accept two arguments:
* - (string) $key
* - (string) $value
*
* @param callable $closure Evaluation function
*
* @return Collection
*/
public function filter(callable $closure)
{
$collection = new static();
foreach ($this->data as $key => $value) {
if ($closure($key, $value)) {
$collection[$key] = $value;
}
}
return $collection;
}
}

View File

@@ -0,0 +1,248 @@
<?php
namespace GuzzleHttp\Cookie;
use GuzzleHttp\Message\RequestInterface;
use GuzzleHttp\Message\ResponseInterface;
use GuzzleHttp\ToArrayInterface;
/**
* Cookie jar that stores cookies an an array
*/
class CookieJar implements CookieJarInterface, ToArrayInterface
{
/** @var SetCookie[] Loaded cookie data */
private $cookies = [];
/** @var bool */
private $strictMode;
/**
* @param bool $strictMode Set to true to throw exceptions when invalid
* cookies are added to the cookie jar.
* @param array $cookieArray Array of SetCookie objects or a hash of arrays
* that can be used with the SetCookie constructor
*/
public function __construct($strictMode = false, $cookieArray = [])
{
$this->strictMode = $strictMode;
foreach ($cookieArray as $cookie) {
if (!($cookie instanceof SetCookie)) {
$cookie = new SetCookie($cookie);
}
$this->setCookie($cookie);
}
}
/**
* Create a new Cookie jar from an associative array and domain.
*
* @param array $cookies Cookies to create the jar from
* @param string $domain Domain to set the cookies to
*
* @return self
*/
public static function fromArray(array $cookies, $domain)
{
$cookieJar = new self();
foreach ($cookies as $name => $value) {
$cookieJar->setCookie(new SetCookie([
'Domain' => $domain,
'Name' => $name,
'Value' => $value,
'Discard' => true
]));
}
return $cookieJar;
}
/**
* Quote the cookie value if it is not already quoted and it contains
* problematic characters.
*
* @param string $value Value that may or may not need to be quoted
*
* @return string
*/
public static function getCookieValue($value)
{
if (substr($value, 0, 1) !== '"' &&
substr($value, -1, 1) !== '"' &&
strpbrk($value, ';,')
) {
$value = '"' . $value . '"';
}
return $value;
}
public function toArray()
{
return array_map(function (SetCookie $cookie) {
return $cookie->toArray();
}, $this->getIterator()->getArrayCopy());
}
public function clear($domain = null, $path = null, $name = null)
{
if (!$domain) {
$this->cookies = [];
return;
} elseif (!$path) {
$this->cookies = array_filter(
$this->cookies,
function (SetCookie $cookie) use ($path, $domain) {
return !$cookie->matchesDomain($domain);
}
);
} elseif (!$name) {
$this->cookies = array_filter(
$this->cookies,
function (SetCookie $cookie) use ($path, $domain) {
return !($cookie->matchesPath($path) &&
$cookie->matchesDomain($domain));
}
);
} else {
$this->cookies = array_filter(
$this->cookies,
function (SetCookie $cookie) use ($path, $domain, $name) {
return !($cookie->getName() == $name &&
$cookie->matchesPath($path) &&
$cookie->matchesDomain($domain));
}
);
}
}
public function clearSessionCookies()
{
$this->cookies = array_filter(
$this->cookies,
function (SetCookie $cookie) {
return !$cookie->getDiscard() && $cookie->getExpires();
}
);
}
public function setCookie(SetCookie $cookie)
{
// Only allow cookies with set and valid domain, name, value
$result = $cookie->validate();
if ($result !== true) {
if ($this->strictMode) {
throw new \RuntimeException('Invalid cookie: ' . $result);
} else {
$this->removeCookieIfEmpty($cookie);
return false;
}
}
// Resolve conflicts with previously set cookies
foreach ($this->cookies as $i => $c) {
// Two cookies are identical, when their path, and domain are
// identical.
if ($c->getPath() != $cookie->getPath() ||
$c->getDomain() != $cookie->getDomain() ||
$c->getName() != $cookie->getName()
) {
continue;
}
// The previously set cookie is a discard cookie and this one is
// not so allow the new cookie to be set
if (!$cookie->getDiscard() && $c->getDiscard()) {
unset($this->cookies[$i]);
continue;
}
// If the new cookie's expiration is further into the future, then
// replace the old cookie
if ($cookie->getExpires() > $c->getExpires()) {
unset($this->cookies[$i]);
continue;
}
// If the value has changed, we better change it
if ($cookie->getValue() !== $c->getValue()) {
unset($this->cookies[$i]);
continue;
}
// The cookie exists, so no need to continue
return false;
}
$this->cookies[] = $cookie;
return true;
}
public function count()
{
return count($this->cookies);
}
public function getIterator()
{
return new \ArrayIterator(array_values($this->cookies));
}
public function extractCookies(
RequestInterface $request,
ResponseInterface $response
) {
if ($cookieHeader = $response->getHeaderAsArray('Set-Cookie')) {
foreach ($cookieHeader as $cookie) {
$sc = SetCookie::fromString($cookie);
if (!$sc->getDomain()) {
$sc->setDomain($request->getHost());
}
$this->setCookie($sc);
}
}
}
public function addCookieHeader(RequestInterface $request)
{
$values = [];
$scheme = $request->getScheme();
$host = $request->getHost();
$path = $request->getPath();
foreach ($this->cookies as $cookie) {
if ($cookie->matchesPath($path) &&
$cookie->matchesDomain($host) &&
!$cookie->isExpired() &&
(!$cookie->getSecure() || $scheme == 'https')
) {
$values[] = $cookie->getName() . '='
. self::getCookieValue($cookie->getValue());
}
}
if ($values) {
$request->setHeader('Cookie', implode('; ', $values));
}
}
/**
* If a cookie already exists and the server asks to set it again with a
* null value, the cookie must be deleted.
*
* @param SetCookie $cookie
*/
private function removeCookieIfEmpty(SetCookie $cookie)
{
$cookieValue = $cookie->getValue();
if ($cookieValue === null || $cookieValue === '') {
$this->clear(
$cookie->getDomain(),
$cookie->getPath(),
$cookie->getName()
);
}
}
}

View File

@@ -0,0 +1,75 @@
<?php
namespace GuzzleHttp\Cookie;
use GuzzleHttp\Message\RequestInterface;
use GuzzleHttp\Message\ResponseInterface;
/**
* Stores HTTP cookies.
*
* It extracts cookies from HTTP requests, and returns them in HTTP responses.
* CookieJarInterface instances automatically expire contained cookies when
* necessary. Subclasses are also responsible for storing and retrieving
* cookies from a file, database, etc.
*
* @link http://docs.python.org/2/library/cookielib.html Inspiration
*/
interface CookieJarInterface extends \Countable, \IteratorAggregate
{
/**
* Add a Cookie header to a request.
*
* If no matching cookies are found in the cookie jar, then no Cookie
* header is added to the request.
*
* @param RequestInterface $request Request object to update
*/
public function addCookieHeader(RequestInterface $request);
/**
* Extract cookies from an HTTP response and store them in the CookieJar.
*
* @param RequestInterface $request Request that was sent
* @param ResponseInterface $response Response that was received
*/
public function extractCookies(
RequestInterface $request,
ResponseInterface $response
);
/**
* Sets a cookie in the cookie jar.
*
* @param SetCookie $cookie Cookie to set.
*
* @return bool Returns true on success or false on failure
*/
public function setCookie(SetCookie $cookie);
/**
* Remove cookies currently held in the cookie jar.
*
* Invoking this method without arguments will empty the whole cookie jar.
* If given a $domain argument only cookies belonging to that domain will
* be removed. If given a $domain and $path argument, cookies belonging to
* the specified path within that domain are removed. If given all three
* arguments, then the cookie with the specified name, path and domain is
* removed.
*
* @param string $domain Clears cookies matching a domain
* @param string $path Clears cookies matching a domain and path
* @param string $name Clears cookies matching a domain, path, and name
*
* @return CookieJarInterface
*/
public function clear($domain = null, $path = null, $name = null);
/**
* Discard all sessions cookies.
*
* Removes cookies that don't have an expire field or a have a discard
* field set to true. To be called when the user agent shuts down according
* to RFC 2965.
*/
public function clearSessionCookies();
}

View File

@@ -0,0 +1,86 @@
<?php
namespace GuzzleHttp\Cookie;
use GuzzleHttp\Utils;
/**
* Persists non-session cookies using a JSON formatted file
*/
class FileCookieJar extends CookieJar
{
/** @var string filename */
private $filename;
/**
* Create a new FileCookieJar object
*
* @param string $cookieFile File to store the cookie data
*
* @throws \RuntimeException if the file cannot be found or created
*/
public function __construct($cookieFile)
{
$this->filename = $cookieFile;
if (file_exists($cookieFile)) {
$this->load($cookieFile);
}
}
/**
* Saves the file when shutting down
*/
public function __destruct()
{
$this->save($this->filename);
}
/**
* Saves the cookies to a file.
*
* @param string $filename File to save
* @throws \RuntimeException if the file cannot be found or created
*/
public function save($filename)
{
$json = [];
foreach ($this as $cookie) {
if ($cookie->getExpires() && !$cookie->getDiscard()) {
$json[] = $cookie->toArray();
}
}
if (false === file_put_contents($filename, json_encode($json), LOCK_EX)) {
// @codeCoverageIgnoreStart
throw new \RuntimeException("Unable to save file {$filename}");
// @codeCoverageIgnoreEnd
}
}
/**
* Load cookies from a JSON formatted file.
*
* Old cookies are kept unless overwritten by newly loaded ones.
*
* @param string $filename Cookie file to load.
* @throws \RuntimeException if the file cannot be loaded.
*/
public function load($filename)
{
$json = file_get_contents($filename);
if (false === $json) {
// @codeCoverageIgnoreStart
throw new \RuntimeException("Unable to load file {$filename}");
// @codeCoverageIgnoreEnd
}
$data = Utils::jsonDecode($json, true);
if (is_array($data)) {
foreach (Utils::jsonDecode($json, true) as $cookie) {
$this->setCookie(new SetCookie($cookie));
}
} elseif (strlen($data)) {
throw new \RuntimeException("Invalid cookie file: {$filename}");
}
}
}

View File

@@ -0,0 +1,66 @@
<?php
namespace GuzzleHttp\Cookie;
use GuzzleHttp\Utils;
/**
* Persists cookies in the client session
*/
class SessionCookieJar extends CookieJar
{
/** @var string session key */
private $sessionKey;
/**
* Create a new SessionCookieJar object
*
* @param string $sessionKey Session key name to store the cookie data in session
*/
public function __construct($sessionKey)
{
$this->sessionKey = $sessionKey;
$this->load();
}
/**
* Saves cookies to session when shutting down
*/
public function __destruct()
{
$this->save();
}
/**
* Save cookies to the client session
*/
public function save()
{
$json = [];
foreach ($this as $cookie) {
if ($cookie->getExpires() && !$cookie->getDiscard()) {
$json[] = $cookie->toArray();
}
}
$_SESSION[$this->sessionKey] = json_encode($json);
}
/**
* Load the contents of the client session into the data array
*/
protected function load()
{
$cookieJar = isset($_SESSION[$this->sessionKey])
? $_SESSION[$this->sessionKey]
: null;
$data = Utils::jsonDecode($cookieJar, true);
if (is_array($data)) {
foreach ($data as $cookie) {
$this->setCookie(new SetCookie($cookie));
}
} elseif (strlen($data)) {
throw new \RuntimeException("Invalid cookie data");
}
}
}

View File

@@ -0,0 +1,373 @@
<?php
namespace GuzzleHttp\Cookie;
use GuzzleHttp\ToArrayInterface;
/**
* Set-Cookie object
*/
class SetCookie implements ToArrayInterface
{
/** @var array */
private static $defaults = [
'Name' => null,
'Value' => null,
'Domain' => null,
'Path' => '/',
'Max-Age' => null,
'Expires' => null,
'Secure' => false,
'Discard' => false,
'HttpOnly' => false
];
/** @var array Cookie data */
private $data;
/**
* Create a new SetCookie object from a string
*
* @param string $cookie Set-Cookie header string
*
* @return self
*/
public static function fromString($cookie)
{
// Create the default return array
$data = self::$defaults;
// Explode the cookie string using a series of semicolons
$pieces = array_filter(array_map('trim', explode(';', $cookie)));
// The name of the cookie (first kvp) must include an equal sign.
if (empty($pieces) || !strpos($pieces[0], '=')) {
return new self($data);
}
// Add the cookie pieces into the parsed data array
foreach ($pieces as $part) {
$cookieParts = explode('=', $part, 2);
$key = trim($cookieParts[0]);
$value = isset($cookieParts[1])
? trim($cookieParts[1], " \n\r\t\0\x0B\"")
: true;
// Only check for non-cookies when cookies have been found
if (empty($data['Name'])) {
$data['Name'] = $key;
$data['Value'] = $value;
} else {
foreach (array_keys(self::$defaults) as $search) {
if (!strcasecmp($search, $key)) {
$data[$search] = $value;
continue 2;
}
}
$data[$key] = $value;
}
}
return new self($data);
}
/**
* @param array $data Array of cookie data provided by a Cookie parser
*/
public function __construct(array $data = [])
{
$this->data = array_replace(self::$defaults, $data);
// Extract the Expires value and turn it into a UNIX timestamp if needed
if (!$this->getExpires() && $this->getMaxAge()) {
// Calculate the Expires date
$this->setExpires(time() + $this->getMaxAge());
} elseif ($this->getExpires() && !is_numeric($this->getExpires())) {
$this->setExpires($this->getExpires());
}
}
public function __toString()
{
$str = $this->data['Name'] . '=' . $this->data['Value'] . '; ';
foreach ($this->data as $k => $v) {
if ($k != 'Name' && $k != 'Value' && $v !== null && $v !== false) {
if ($k == 'Expires') {
$str .= 'Expires=' . gmdate('D, d M Y H:i:s \G\M\T', $v) . '; ';
} else {
$str .= ($v === true ? $k : "{$k}={$v}") . '; ';
}
}
}
return rtrim($str, '; ');
}
public function toArray()
{
return $this->data;
}
/**
* Get the cookie name
*
* @return string
*/
public function getName()
{
return $this->data['Name'];
}
/**
* Set the cookie name
*
* @param string $name Cookie name
*/
public function setName($name)
{
$this->data['Name'] = $name;
}
/**
* Get the cookie value
*
* @return string
*/
public function getValue()
{
return $this->data['Value'];
}
/**
* Set the cookie value
*
* @param string $value Cookie value
*/
public function setValue($value)
{
$this->data['Value'] = $value;
}
/**
* Get the domain
*
* @return string|null
*/
public function getDomain()
{
return $this->data['Domain'];
}
/**
* Set the domain of the cookie
*
* @param string $domain
*/
public function setDomain($domain)
{
$this->data['Domain'] = $domain;
}
/**
* Get the path
*
* @return string
*/
public function getPath()
{
return $this->data['Path'];
}
/**
* Set the path of the cookie
*
* @param string $path Path of the cookie
*/
public function setPath($path)
{
$this->data['Path'] = $path;
}
/**
* Maximum lifetime of the cookie in seconds
*
* @return int|null
*/
public function getMaxAge()
{
return $this->data['Max-Age'];
}
/**
* Set the max-age of the cookie
*
* @param int $maxAge Max age of the cookie in seconds
*/
public function setMaxAge($maxAge)
{
$this->data['Max-Age'] = $maxAge;
}
/**
* The UNIX timestamp when the cookie Expires
*
* @return mixed
*/
public function getExpires()
{
return $this->data['Expires'];
}
/**
* Set the unix timestamp for which the cookie will expire
*
* @param int $timestamp Unix timestamp
*/
public function setExpires($timestamp)
{
$this->data['Expires'] = is_numeric($timestamp)
? (int) $timestamp
: strtotime($timestamp);
}
/**
* Get whether or not this is a secure cookie
*
* @return null|bool
*/
public function getSecure()
{
return $this->data['Secure'];
}
/**
* Set whether or not the cookie is secure
*
* @param bool $secure Set to true or false if secure
*/
public function setSecure($secure)
{
$this->data['Secure'] = $secure;
}
/**
* Get whether or not this is a session cookie
*
* @return null|bool
*/
public function getDiscard()
{
return $this->data['Discard'];
}
/**
* Set whether or not this is a session cookie
*
* @param bool $discard Set to true or false if this is a session cookie
*/
public function setDiscard($discard)
{
$this->data['Discard'] = $discard;
}
/**
* Get whether or not this is an HTTP only cookie
*
* @return bool
*/
public function getHttpOnly()
{
return $this->data['HttpOnly'];
}
/**
* Set whether or not this is an HTTP only cookie
*
* @param bool $httpOnly Set to true or false if this is HTTP only
*/
public function setHttpOnly($httpOnly)
{
$this->data['HttpOnly'] = $httpOnly;
}
/**
* Check if the cookie matches a path value
*
* @param string $path Path to check against
*
* @return bool
*/
public function matchesPath($path)
{
return !$this->getPath() || 0 === stripos($path, $this->getPath());
}
/**
* Check if the cookie matches a domain value
*
* @param string $domain Domain to check against
*
* @return bool
*/
public function matchesDomain($domain)
{
// Remove the leading '.' as per spec in RFC 6265.
// http://tools.ietf.org/html/rfc6265#section-5.2.3
$cookieDomain = ltrim($this->getDomain(), '.');
// Domain not set or exact match.
if (!$cookieDomain || !strcasecmp($domain, $cookieDomain)) {
return true;
}
// Matching the subdomain according to RFC 6265.
// http://tools.ietf.org/html/rfc6265#section-5.1.3
if (filter_var($domain, FILTER_VALIDATE_IP)) {
return false;
}
return (bool) preg_match('/\.' . preg_quote($cookieDomain) . '$/i', $domain);
}
/**
* Check if the cookie is expired
*
* @return bool
*/
public function isExpired()
{
return $this->getExpires() !== null && time() > $this->getExpires();
}
/**
* Check if the cookie is valid according to RFC 6265
*
* @return bool|string Returns true if valid or an error message if invalid
*/
public function validate()
{
// Names must not be empty, but can be 0
$name = $this->getName();
if (empty($name) && !is_numeric($name)) {
return 'The cookie name must not be empty';
}
// Check if any of the invalid characters are present in the cookie name
if (preg_match("/[=,; \t\r\n\013\014]/", $name)) {
return "Cookie name must not cannot invalid characters: =,; \\t\\r\\n\\013\\014";
}
// Value must not be empty, but can be 0
$value = $this->getValue();
if (empty($value) && !is_numeric($value)) {
return 'The cookie value must not be empty';
}
// Domains must not be empty, but can be 0
// A "0" is not a valid internet domain, but may be used as server name
// in a private network.
$domain = $this->getDomain();
if (empty($domain) && !is_numeric($domain)) {
return 'The cookie domain must not be empty';
}
return true;
}
}

View File

@@ -0,0 +1,20 @@
<?php
namespace GuzzleHttp\Event;
/**
* Basic event class that can be extended.
*/
abstract class AbstractEvent implements EventInterface
{
private $propagationStopped = false;
public function isPropagationStopped()
{
return $this->propagationStopped;
}
public function stopPropagation()
{
$this->propagationStopped = true;
}
}

View File

@@ -0,0 +1,61 @@
<?php
namespace GuzzleHttp\Event;
use GuzzleHttp\Transaction;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Message\RequestInterface;
/**
* Base class for request events, providing a request and client getter.
*/
abstract class AbstractRequestEvent extends AbstractEvent
{
/** @var Transaction */
protected $transaction;
/**
* @param Transaction $transaction
*/
public function __construct(Transaction $transaction)
{
$this->transaction = $transaction;
}
/**
* Get the HTTP client associated with the event.
*
* @return ClientInterface
*/
public function getClient()
{
return $this->transaction->client;
}
/**
* Get the request object
*
* @return RequestInterface
*/
public function getRequest()
{
return $this->transaction->request;
}
/**
* Get the number of transaction retries.
*
* @return int
*/
public function getRetryCount()
{
return $this->transaction->retries;
}
/**
* @return Transaction
*/
public function getTransaction()
{
return $this->transaction;
}
}

View File

@@ -0,0 +1,40 @@
<?php
namespace GuzzleHttp\Event;
/**
* Abstract request event that can be retried.
*/
class AbstractRetryableEvent extends AbstractTransferEvent
{
/**
* Mark the request as needing a retry and stop event propagation.
*
* This action allows you to retry a request without emitting the "end"
* event multiple times for a given request. When retried, the request
* emits a before event and is then sent again using the client that sent
* the original request.
*
* When retrying, it is important to limit the number of retries you allow
* to prevent infinite loops.
*
* This action can only be taken during the "complete" and "error" events.
*
* @param int $afterDelay If specified, the amount of time in milliseconds
* to delay before retrying. Note that this must
* be supported by the underlying RingPHP handler
* to work properly. Set to 0 or provide no value
* to retry immediately.
*/
public function retry($afterDelay = 0)
{
// Setting the transition state to 'retry' will cause the next state
// transition of the transaction to retry the request.
$this->transaction->state = 'retry';
if ($afterDelay) {
$this->transaction->request->getConfig()->set('delay', $afterDelay);
}
$this->stopPropagation();
}
}

View File

@@ -0,0 +1,63 @@
<?php
namespace GuzzleHttp\Event;
use GuzzleHttp\Message\ResponseInterface;
use GuzzleHttp\Ring\Future\FutureInterface;
/**
* Event that contains transfer statistics, and can be intercepted.
*/
abstract class AbstractTransferEvent extends AbstractRequestEvent
{
/**
* Get all transfer information as an associative array if no $name
* argument is supplied, or gets a specific transfer statistic if
* a $name attribute is supplied (e.g., 'total_time').
*
* @param string $name Name of the transfer stat to retrieve
*
* @return mixed|null|array
*/
public function getTransferInfo($name = null)
{
if (!$name) {
return $this->transaction->transferInfo;
}
return isset($this->transaction->transferInfo[$name])
? $this->transaction->transferInfo[$name]
: null;
}
/**
* Returns true/false if a response is available.
*
* @return bool
*/
public function hasResponse()
{
return !($this->transaction->response instanceof FutureInterface);
}
/**
* Get the response.
*
* @return ResponseInterface|null
*/
public function getResponse()
{
return $this->hasResponse() ? $this->transaction->response : null;
}
/**
* Intercept the request and associate a response
*
* @param ResponseInterface $response Response to set
*/
public function intercept(ResponseInterface $response)
{
$this->transaction->response = $response;
$this->transaction->exception = null;
$this->stopPropagation();
}
}

View File

@@ -0,0 +1,26 @@
<?php
namespace GuzzleHttp\Event;
use GuzzleHttp\Message\ResponseInterface;
/**
* Event object emitted before a request is sent.
*
* This event MAY be emitted multiple times (i.e., if a request is retried).
* You MAY change the Response associated with the request using the
* intercept() method of the event.
*/
class BeforeEvent extends AbstractRequestEvent
{
/**
* Intercept the request and associate a response
*
* @param ResponseInterface $response Response to set
*/
public function intercept(ResponseInterface $response)
{
$this->transaction->response = $response;
$this->transaction->exception = null;
$this->stopPropagation();
}
}

View File

@@ -0,0 +1,14 @@
<?php
namespace GuzzleHttp\Event;
/**
* Event object emitted after a request has been completed.
*
* This event MAY be emitted multiple times for a single request. You MAY
* change the Response associated with the request using the intercept()
* method of the event.
*
* This event allows the request to be retried if necessary using the retry()
* method of the event.
*/
class CompleteEvent extends AbstractRetryableEvent {}

View File

@@ -0,0 +1,145 @@
<?php
namespace GuzzleHttp\Event;
/**
* Guzzle event emitter.
*
* Some of this class is based on the Symfony EventDispatcher component, which
* ships with the following license:
*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link https://github.com/symfony/symfony/tree/master/src/Symfony/Component/EventDispatcher
*/
class Emitter implements EmitterInterface
{
/** @var array */
private $listeners = [];
/** @var array */
private $sorted = [];
public function on($eventName, callable $listener, $priority = 0)
{
if ($priority === 'first') {
$priority = isset($this->listeners[$eventName])
? max(array_keys($this->listeners[$eventName])) + 1
: 1;
} elseif ($priority === 'last') {
$priority = isset($this->listeners[$eventName])
? min(array_keys($this->listeners[$eventName])) - 1
: -1;
}
$this->listeners[$eventName][$priority][] = $listener;
unset($this->sorted[$eventName]);
}
public function once($eventName, callable $listener, $priority = 0)
{
$onceListener = function (
EventInterface $event
) use (&$onceListener, $eventName, $listener, $priority) {
$this->removeListener($eventName, $onceListener);
$listener($event, $eventName);
};
$this->on($eventName, $onceListener, $priority);
}
public function removeListener($eventName, callable $listener)
{
if (empty($this->listeners[$eventName])) {
return;
}
foreach ($this->listeners[$eventName] as $priority => $listeners) {
if (false !== ($key = array_search($listener, $listeners, true))) {
unset(
$this->listeners[$eventName][$priority][$key],
$this->sorted[$eventName]
);
}
}
}
public function listeners($eventName = null)
{
// Return all events in a sorted priority order
if ($eventName === null) {
foreach (array_keys($this->listeners) as $eventName) {
if (empty($this->sorted[$eventName])) {
$this->listeners($eventName);
}
}
return $this->sorted;
}
// Return the listeners for a specific event, sorted in priority order
if (empty($this->sorted[$eventName])) {
$this->sorted[$eventName] = [];
if (isset($this->listeners[$eventName])) {
krsort($this->listeners[$eventName], SORT_NUMERIC);
foreach ($this->listeners[$eventName] as $listeners) {
foreach ($listeners as $listener) {
$this->sorted[$eventName][] = $listener;
}
}
}
}
return $this->sorted[$eventName];
}
public function hasListeners($eventName)
{
return !empty($this->listeners[$eventName]);
}
public function emit($eventName, EventInterface $event)
{
if (isset($this->listeners[$eventName])) {
foreach ($this->listeners($eventName) as $listener) {
$listener($event, $eventName);
if ($event->isPropagationStopped()) {
break;
}
}
}
return $event;
}
public function attach(SubscriberInterface $subscriber)
{
foreach ($subscriber->getEvents() as $eventName => $listeners) {
if (is_array($listeners[0])) {
foreach ($listeners as $listener) {
$this->on(
$eventName,
[$subscriber, $listener[0]],
isset($listener[1]) ? $listener[1] : 0
);
}
} else {
$this->on(
$eventName,
[$subscriber, $listeners[0]],
isset($listeners[1]) ? $listeners[1] : 0
);
}
}
}
public function detach(SubscriberInterface $subscriber)
{
foreach ($subscriber->getEvents() as $eventName => $listener) {
$this->removeListener($eventName, [$subscriber, $listener[0]]);
}
}
}

View File

@@ -0,0 +1,96 @@
<?php
namespace GuzzleHttp\Event;
/**
* Guzzle event emitter.
*/
interface EmitterInterface
{
/**
* Binds a listener to a specific event.
*
* @param string $eventName Name of the event to bind to.
* @param callable $listener Listener to invoke when triggered.
* @param int|string $priority The higher this value, the earlier an event
* listener will be triggered in the chain (defaults to 0). You can
* pass "first" or "last" to dynamically specify the event priority
* based on the current event priorities associated with the given
* event name in the emitter. Use "first" to set the priority to the
* current highest priority plus one. Use "last" to set the priority to
* the current lowest event priority minus one.
*/
public function on($eventName, callable $listener, $priority = 0);
/**
* Binds a listener to a specific event. After the listener is triggered
* once, it is removed as a listener.
*
* @param string $eventName Name of the event to bind to.
* @param callable $listener Listener to invoke when triggered.
* @param int $priority The higher this value, the earlier an event
* listener will be triggered in the chain (defaults to 0)
*/
public function once($eventName, callable $listener, $priority = 0);
/**
* Removes an event listener from the specified event.
*
* @param string $eventName The event to remove a listener from
* @param callable $listener The listener to remove
*/
public function removeListener($eventName, callable $listener);
/**
* Gets the listeners of a specific event or all listeners if no event is
* specified.
*
* @param string $eventName The name of the event. Pass null (the default)
* to retrieve all listeners.
*
* @return array The event listeners for the specified event, or all event
* listeners by event name. The format of the array when retrieving a
* specific event list is an array of callables. The format of the array
* when retrieving all listeners is an associative array of arrays of
* callables.
*/
public function listeners($eventName = null);
/**
* Checks if the emitter has listeners by the given name.
*
* @param string $eventName The name of the event to check.
*
* @return bool
*/
public function hasListeners($eventName);
/**
* Emits an event to all registered listeners.
*
* Each event that is bound to the emitted eventName receives a
* EventInterface, the name of the event, and the event emitter.
*
* @param string $eventName The name of the event to dispatch.
* @param EventInterface $event The event to pass to the event handlers/listeners.
*
* @return EventInterface Returns the provided event object
*/
public function emit($eventName, EventInterface $event);
/**
* Attaches an event subscriber.
*
* The subscriber is asked for all the events it is interested in and added
* as an event listener for each event.
*
* @param SubscriberInterface $subscriber Subscriber to attach.
*/
public function attach(SubscriberInterface $subscriber);
/**
* Detaches an event subscriber.
*
* @param SubscriberInterface $subscriber Subscriber to detach.
*/
public function detach(SubscriberInterface $subscriber);
}

View File

@@ -0,0 +1,28 @@
<?php
namespace GuzzleHttp\Event;
/**
* A terminal event that is emitted when a request transaction has ended.
*
* This event is emitted for both successful responses and responses that
* encountered an exception. You need to check if an exception is present
* in your listener to know the difference.
*
* You MAY intercept the response associated with the event if needed, but keep
* in mind that the "complete" event will not be triggered as a result.
*/
class EndEvent extends AbstractTransferEvent
{
/**
* Get the exception that was encountered (if any).
*
* This method should be used to check if the request was sent successfully
* or if it encountered errors.
*
* @return \Exception|null
*/
public function getException()
{
return $this->transaction->exception;
}
}

View File

@@ -0,0 +1,27 @@
<?php
namespace GuzzleHttp\Event;
use GuzzleHttp\Exception\RequestException;
/**
* Event emitted when an error occurs while sending a request.
*
* This event MAY be emitted multiple times. You MAY intercept the exception
* and inject a response into the event to rescue the request using the
* intercept() method of the event.
*
* This event allows the request to be retried using the "retry" method of the
* event.
*/
class ErrorEvent extends AbstractRetryableEvent
{
/**
* Get the exception that was encountered
*
* @return RequestException
*/
public function getException()
{
return $this->transaction->exception;
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace GuzzleHttp\Event;
/**
* Base event interface used when dispatching events to listeners using an
* event emitter.
*/
interface EventInterface
{
/**
* Returns whether or not stopPropagation was called on the event.
*
* @return bool
* @see Event::stopPropagation
*/
public function isPropagationStopped();
/**
* Stops the propagation of the event, preventing subsequent listeners
* registered to the same event from being invoked.
*/
public function stopPropagation();
}

View File

@@ -0,0 +1,15 @@
<?php
namespace GuzzleHttp\Event;
/**
* Holds an event emitter
*/
interface HasEmitterInterface
{
/**
* Get the event emitter of the object
*
* @return EmitterInterface
*/
public function getEmitter();
}

View File

@@ -0,0 +1,20 @@
<?php
namespace GuzzleHttp\Event;
/**
* Trait that implements the methods of HasEmitterInterface
*/
trait HasEmitterTrait
{
/** @var EmitterInterface */
private $emitter;
public function getEmitter()
{
if (!$this->emitter) {
$this->emitter = new Emitter();
}
return $this->emitter;
}
}

View File

@@ -0,0 +1,88 @@
<?php
namespace GuzzleHttp\Event;
/**
* Trait that provides methods for extract event listeners specified in an array
* and attaching them to an emitter owned by the object or one of its direct
* dependencies.
*/
trait ListenerAttacherTrait
{
/**
* Attaches event listeners and properly sets their priorities and whether
* or not they are are only executed once.
*
* @param HasEmitterInterface $object Object that has the event emitter.
* @param array $listeners Array of hashes representing event
* event listeners. Each item contains
* "name", "fn", "priority", & "once".
*/
private function attachListeners(HasEmitterInterface $object, array $listeners)
{
$emitter = $object->getEmitter();
foreach ($listeners as $el) {
if ($el['once']) {
$emitter->once($el['name'], $el['fn'], $el['priority']);
} else {
$emitter->on($el['name'], $el['fn'], $el['priority']);
}
}
}
/**
* Extracts the allowed events from the provided array, and ignores anything
* else in the array. The event listener must be specified as a callable or
* as an array of event listener data ("name", "fn", "priority", "once").
*
* @param array $source Array containing callables or hashes of data to be
* prepared as event listeners.
* @param array $events Names of events to look for in the provided $source
* array. Other keys are ignored.
* @return array
*/
private function prepareListeners(array $source, array $events)
{
$listeners = [];
foreach ($events as $name) {
if (isset($source[$name])) {
$this->buildListener($name, $source[$name], $listeners);
}
}
return $listeners;
}
/**
* Creates a complete event listener definition from the provided array of
* listener data. Also works recursively if more than one listeners are
* contained in the provided array.
*
* @param string $name Name of the event the listener is for.
* @param array|callable $data Event listener data to prepare.
* @param array $listeners Array of listeners, passed by reference.
*
* @throws \InvalidArgumentException if the event data is malformed.
*/
private function buildListener($name, $data, &$listeners)
{
static $defaults = ['priority' => 0, 'once' => false];
// If a callable is provided, normalize it to the array format.
if (is_callable($data)) {
$data = ['fn' => $data];
}
// Prepare the listener and add it to the array, recursively.
if (isset($data['fn'])) {
$data['name'] = $name;
$listeners[] = $data + $defaults;
} elseif (is_array($data)) {
foreach ($data as $listenerData) {
$this->buildListener($name, $listenerData, $listeners);
}
} else {
throw new \InvalidArgumentException('Each event listener must be a '
. 'callable or an associative array containing a "fn" key.');
}
}
}

View File

@@ -0,0 +1,51 @@
<?php
namespace GuzzleHttp\Event;
use GuzzleHttp\Transaction;
/**
* Event object emitted when upload or download progress is made.
*
* You can access the progress values using their corresponding public
* properties:
*
* - $downloadSize: The number of bytes that will be downloaded (if known)
* - $downloaded: The number of bytes that have been downloaded
* - $uploadSize: The number of bytes that will be uploaded (if known)
* - $uploaded: The number of bytes that have been uploaded
*/
class ProgressEvent extends AbstractRequestEvent
{
/** @var int Amount of data to be downloaded */
public $downloadSize;
/** @var int Amount of data that has been downloaded */
public $downloaded;
/** @var int Amount of data to upload */
public $uploadSize;
/** @var int Amount of data that has been uploaded */
public $uploaded;
/**
* @param Transaction $transaction Transaction being sent.
* @param int $downloadSize Amount of data to download (if known)
* @param int $downloaded Amount of data that has been downloaded
* @param int $uploadSize Amount of data to upload (if known)
* @param int $uploaded Amount of data that had been uploaded
*/
public function __construct(
Transaction $transaction,
$downloadSize,
$downloaded,
$uploadSize,
$uploaded
) {
parent::__construct($transaction);
$this->downloadSize = $downloadSize;
$this->downloaded = $downloaded;
$this->uploadSize = $uploadSize;
$this->uploaded = $uploaded;
}
}

View File

@@ -0,0 +1,56 @@
<?php
namespace GuzzleHttp\Event;
/**
* Contains methods used to manage the request event lifecycle.
*/
final class RequestEvents
{
// Generic event priorities
const EARLY = 10000;
const LATE = -10000;
// "before" priorities
const PREPARE_REQUEST = -100;
const SIGN_REQUEST = -10000;
// "complete" and "error" response priorities
const VERIFY_RESPONSE = 100;
const REDIRECT_RESPONSE = 200;
/**
* Converts an array of event options into a formatted array of valid event
* configuration.
*
* @param array $options Event array to convert
* @param array $events Event names to convert in the options array.
* @param mixed $handler Event handler to utilize
*
* @return array
* @throws \InvalidArgumentException if the event config is invalid
* @internal
*/
public static function convertEventArray(
array $options,
array $events,
$handler
) {
foreach ($events as $name) {
if (!isset($options[$name])) {
$options[$name] = [$handler];
} elseif (is_callable($options[$name])) {
$options[$name] = [$options[$name], $handler];
} elseif (is_array($options[$name])) {
if (isset($options[$name]['fn'])) {
$options[$name] = [$options[$name], $handler];
} else {
$options[$name][] = $handler;
}
} else {
throw new \InvalidArgumentException('Invalid event format');
}
}
return $options;
}
}

View File

@@ -0,0 +1,34 @@
<?php
namespace GuzzleHttp\Event;
/**
* SubscriberInterface provides an array of events to an
* EventEmitterInterface when it is registered. The emitter then binds the
* listeners specified by the EventSubscriber.
*
* This interface is based on the SubscriberInterface of the Symfony.
* @link https://github.com/symfony/symfony/tree/master/src/Symfony/Component/EventDispatcher
*/
interface SubscriberInterface
{
/**
* Returns an array of event names this subscriber wants to listen to.
*
* The returned array keys MUST map to an event name. Each array value
* MUST be an array in which the first element is the name of a function
* on the EventSubscriber OR an array of arrays in the aforementioned
* format. The second element in the array is optional, and if specified,
* designates the event priority.
*
* For example, the following are all valid:
*
* - ['eventName' => ['methodName']]
* - ['eventName' => ['methodName', $priority]]
* - ['eventName' => [['methodName'], ['otherMethod']]
* - ['eventName' => [['methodName'], ['otherMethod', $priority]]
* - ['eventName' => [['methodName', $priority], ['otherMethod', $priority]]
*
* @return array
*/
public function getEvents();
}

View File

@@ -0,0 +1,7 @@
<?php
namespace GuzzleHttp\Exception;
/**
* Exception when an HTTP error occurs (4xx or 5xx error)
*/
class BadResponseException extends RequestException {}

View File

@@ -0,0 +1,7 @@
<?php
namespace GuzzleHttp\Exception;
/**
* Exception when a client error is encountered (4xx codes)
*/
class ClientException extends BadResponseException {}

View File

@@ -0,0 +1,4 @@
<?php
namespace GuzzleHttp\Exception;
class ConnectException extends RequestException {}

View File

@@ -0,0 +1,4 @@
<?php
namespace GuzzleHttp\Exception;
class CouldNotRewindStreamException extends RequestException {}

View File

@@ -0,0 +1,31 @@
<?php
namespace GuzzleHttp\Exception;
use GuzzleHttp\Message\ResponseInterface;
/**
* Exception when a client is unable to parse the response body as XML or JSON
*/
class ParseException extends TransferException
{
/** @var ResponseInterface */
private $response;
public function __construct(
$message = '',
ResponseInterface $response = null,
\Exception $previous = null
) {
parent::__construct($message, 0, $previous);
$this->response = $response;
}
/**
* Get the associated response
*
* @return ResponseInterface|null
*/
public function getResponse()
{
return $this->response;
}
}

View File

@@ -0,0 +1,121 @@
<?php
namespace GuzzleHttp\Exception;
use GuzzleHttp\Message\RequestInterface;
use GuzzleHttp\Message\ResponseInterface;
use GuzzleHttp\Ring\Exception\ConnectException;
use GuzzleHttp\Exception\ConnectException as HttpConnectException;
use GuzzleHttp\Ring\Future\FutureInterface;
/**
* HTTP Request exception
*/
class RequestException extends TransferException
{
/** @var RequestInterface */
private $request;
/** @var ResponseInterface */
private $response;
public function __construct(
$message,
RequestInterface $request,
ResponseInterface $response = null,
\Exception $previous = null
) {
// Set the code of the exception if the response is set and not future.
$code = $response && !($response instanceof FutureInterface)
? $response->getStatusCode()
: 0;
parent::__construct($message, $code, $previous);
$this->request = $request;
$this->response = $response;
}
/**
* Wrap non-RequestExceptions with a RequestException
*
* @param RequestInterface $request
* @param \Exception $e
*
* @return RequestException
*/
public static function wrapException(RequestInterface $request, \Exception $e)
{
if ($e instanceof RequestException) {
return $e;
} elseif ($e instanceof ConnectException) {
return new HttpConnectException($e->getMessage(), $request, null, $e);
} else {
return new RequestException($e->getMessage(), $request, null, $e);
}
}
/**
* Factory method to create a new exception with a normalized error message
*
* @param RequestInterface $request Request
* @param ResponseInterface $response Response received
* @param \Exception $previous Previous exception
*
* @return self
*/
public static function create(
RequestInterface $request,
ResponseInterface $response = null,
\Exception $previous = null
) {
if (!$response) {
return new self('Error completing request', $request, null, $previous);
}
$level = floor($response->getStatusCode() / 100);
if ($level == '4') {
$label = 'Client error response';
$className = __NAMESPACE__ . '\\ClientException';
} elseif ($level == '5') {
$label = 'Server error response';
$className = __NAMESPACE__ . '\\ServerException';
} else {
$label = 'Unsuccessful response';
$className = __CLASS__;
}
$message = $label . ' [url] ' . $request->getUrl()
. ' [status code] ' . $response->getStatusCode()
. ' [reason phrase] ' . $response->getReasonPhrase();
return new $className($message, $request, $response, $previous);
}
/**
* Get the request that caused the exception
*
* @return RequestInterface
*/
public function getRequest()
{
return $this->request;
}
/**
* Get the associated response
*
* @return ResponseInterface|null
*/
public function getResponse()
{
return $this->response;
}
/**
* Check if a response was received
*
* @return bool
*/
public function hasResponse()
{
return $this->response !== null;
}
}

View File

@@ -0,0 +1,7 @@
<?php
namespace GuzzleHttp\Exception;
/**
* Exception when a server error is encountered (5xx codes)
*/
class ServerException extends BadResponseException {}

View File

@@ -0,0 +1,4 @@
<?php
namespace GuzzleHttp\Exception;
class StateException extends TransferException {};

View File

@@ -0,0 +1,4 @@
<?php
namespace GuzzleHttp\Exception;
class TooManyRedirectsException extends RequestException {}

Some files were not shown because too many files have changed in this diff Show More