* @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ declare(strict_types=1); namespace PrestaShop\Module\Mbo\Traits\Hooks; use PrestaShop\Module\Mbo\Helpers\Config; trait UseActionObjectShopUrlUpdateAfter { /** * @param array $params * * @return bool */ public function hookActionObjectShopUrlUpdateAfter(array $params): bool { if ($params['object']->main) { // Clear cache to be sure to load correctly the shop with good data whe building the service later \Cache::clean('Shop::setUrl_' . (int) $params['object']->id_shop); if (Config::isUsingSecureProtocol()) { $url = 'https://' . preg_replace('#https?://#', '', $params['object']->domain_ssl); } else { $url = 'http://' . preg_replace('#https?://#', '', $params['object']->domain); } $this->updateShop([ 'shop_url' => $url, ]); } return true; } }