<?php declare(strict_types=1);
namespace Mhsp\MhspAddCheckoutShippingInput6;
/**
* Add dependencies from composer
*/
if(file_exists(dirname(__DIR__) . "/vendor/autoload.php")) {
require_once dirname(__DIR__) . '/vendor/autoload.php';
}
use Mhsp\MhspAddCheckoutShippingInput6\Core\Plugin;
use Shopware\Core\Framework\Plugin\Context\InstallContext;
use Shopware\Core\System\SystemConfig\SystemConfigService;
use Symfony\Component\DependencyInjection\ContainerBuilder;
/**
* Class MhspAddCheckoutShippingInput6
*
* @package Mhsp\MhspAddCheckoutShippingInput6
* @author OU <shopware@mediahaus.de>
* @copyright Copyright (c) MEDIAHAUS - Die Medienmanager (http://www.mediahaus.de)
*/
class MhspAddCheckoutShippingInput6 extends Plugin
{
/** @var string */
const PLUGIN_NAME = "MhspAddCheckoutShippingInput6";
/** @var string */
const CONFIG_DOMAIN = self::PLUGIN_NAME . ".config";
/** @var string */
const CONFIG_DELIVERY_IDS = self::CONFIG_DOMAIN . ".deliveryIds";
/** @var string */
const CONFIG_SHOW_INPUT = self::CONFIG_DOMAIN . ".showInput";
/** @var string */
const CONFIG_SYNC_PHONE = self::CONFIG_DOMAIN . ".syncPhone";
/** @var string */
const CONFIG_AUTO_FOCUS = self::CONFIG_DOMAIN . ".autoFocus";
/** @var string */
const CONFIG_SHOW_IN_ORDER_DETAILS = self::CONFIG_DOMAIN . ".showInOrderDetails";
/** @var string */
const CONFIG_SHOW_CUSTOM_PLACEHOLDER = self::CONFIG_DOMAIN . ".showCustomPlaceholder";
/** @var string */
const CONFIG_CUSTOM_PLACEHOLDER = self::CONFIG_DOMAIN . ".customPlaceholder";
/** @var string */
const ROUTE_ORDER = "frontend.checkout.finish.order";
/** @var string */
const PAYPAL_SWITCH_CONTEXT = "store-api.switch-context";
/** @var string */
const PHONE_NUMBER_DEFINITION_NAME = "phoneNumber";
/** @var string */
const CUSTOM_PHONE_NAME ="mhsp-shipping-phone";
/** @var string */
const ORDER_VALIDATION_CREATE = "framework.validation.order.create";
/** @var string */
const VALIDATED_NUMBER_ISO = "mhsp-validated-country-iso";
/**
* @param ContainerBuilder $container
*/
public function build(ContainerBuilder $container): void
{
parent::build($container);
$container->setParameter($this->getContainerPrefix().".plugin_name", $this->getName());
$container->setParameter($this->getContainerPrefix().".plugin_path", $this->getPath());
}
public function install(InstallContext $installContext): void
{
parent::install($installContext);
$this->setIfNotExists(self::CONFIG_SYNC_PHONE, false);
$this->setIfNotExists(self::CONFIG_AUTO_FOCUS, false);
$this->setIfNotExists(self::CONFIG_SHOW_INPUT, false);
$this->setIfNotExists(self::CONFIG_SHOW_IN_ORDER_DETAILS, true);
$this->setIfNotExists(self::CONFIG_DELIVERY_IDS, []);
}
private function setIfNotExists(string $key, $value){
/** @var SystemConfigService $configService */
$configService = $this->container->get(SystemConfigService::class);
if($configService->get($key) !== null){
return;
}
$configService->set($key,$value);
}
}