first commit
This commit is contained in:
56
modules/ps_facebook/controllers/front/Ajax.php
Normal file
56
modules/ps_facebook/controllers/front/Ajax.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* 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 and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
use PrestaShop\Module\PrestashopFacebook\Handler\ApiConversionHandler;
|
||||
use PrestaShop\Module\PrestashopFacebook\Provider\EventDataProvider;
|
||||
|
||||
class Ps_facebookAjaxModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
/** @var Ps_facebook */
|
||||
public $module;
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if ('CustomizeProduct' === Tools::getValue('action')) {
|
||||
return $this->postProcessCustomizeProduct();
|
||||
}
|
||||
}
|
||||
|
||||
private function postProcessCustomizeProduct()
|
||||
{
|
||||
$productId = Tools::getValue('id_product');
|
||||
$attributeIds = Tools::getValue('attribute_ids');
|
||||
if (!$productId || !$attributeIds) {
|
||||
return;
|
||||
}
|
||||
|
||||
$params = [
|
||||
'productId' => $productId,
|
||||
'attributeIds' => $attributeIds,
|
||||
];
|
||||
|
||||
/** @var EventDataProvider $eventDataProvider */
|
||||
$eventDataProvider = $this->module->getService(EventDataProvider::class);
|
||||
$apiConversionHandler = $this->module->getService(ApiConversionHandler::class);
|
||||
|
||||
$eventData = $eventDataProvider->generateEventData('customizeProduct', $params);
|
||||
$apiConversionHandler->handleEvent($eventData);
|
||||
}
|
||||
}
|
||||
104
modules/ps_facebook/controllers/front/apiHealthCheck.php
Normal file
104
modules/ps_facebook/controllers/front/apiHealthCheck.php
Normal file
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* 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 and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
use PrestaShop\Module\PrestashopFacebook\Repository\ServerInformationRepository;
|
||||
|
||||
class Ps_FacebookApiHealthCheckModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
/** @var Ps_facebook */
|
||||
public $module;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function postProcess()
|
||||
{
|
||||
/** @var ServerInformationRepository $serverInformationRepository */
|
||||
$serverInformationRepository = $this->module->getService(ServerInformationRepository::class);
|
||||
|
||||
$status = $serverInformationRepository->getHealthCheckData();
|
||||
|
||||
$this->exitWithResponse($status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Override displayMaintenancePage to prevent the maintenance page to be displayed
|
||||
*
|
||||
* @see FrontController::displayMaintenancePage()
|
||||
*/
|
||||
protected function displayMaintenancePage()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Override displayRestrictedCountryPage to prevent page country is not allowed
|
||||
*
|
||||
* @see FrontController::displayRestrictedCountryPage()
|
||||
*/
|
||||
protected function displayRestrictedCountryPage()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Override geolocationManagement to prevent country GEOIP blocking
|
||||
*
|
||||
* @see FrontController::geolocationManagement()
|
||||
*
|
||||
* @param Country $defaultCountry
|
||||
*
|
||||
* @return false
|
||||
*/
|
||||
protected function geolocationManagement($defaultCountry)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $response
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function exitWithResponse(array $response)
|
||||
{
|
||||
$httpCode = isset($response['httpCode']) ? (int) $response['httpCode'] : 200;
|
||||
|
||||
$this->dieWithResponse($response, $httpCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $response
|
||||
* @param int $code
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function dieWithResponse(array $response, $code)
|
||||
{
|
||||
$httpStatusText = "HTTP/1.1 $code";
|
||||
$response['httpCode'] = (int) $code;
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
|
||||
header('Content-Type: application/json;charset=utf-8');
|
||||
header($httpStatusText);
|
||||
|
||||
echo json_encode($response, JSON_UNESCAPED_SLASHES);
|
||||
|
||||
exit;
|
||||
}
|
||||
}
|
||||
28
modules/ps_facebook/controllers/front/index.php
Normal file
28
modules/ps_facebook/controllers/front/index.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* 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 and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
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;
|
||||
Reference in New Issue
Block a user