1<?php 2/** 3 * Copyright since 2007 PrestaShop SA and Contributors 4 * PrestaShop is an International Registered Trademark & Property of PrestaShop SA 5 * 6 * NOTICE OF LICENSE 7 * 8 * This source file is subject to the Open Software License (OSL 3.0) 9 * that is bundled with this package in the file LICENSE.md. 10 * It is also available through the world-wide-web at this URL: 11 * https://opensource.org/licenses/OSL-3.0 12 * If you did not receive a copy of the license and are unable to 13 * obtain it through the world-wide-web, please send an email 14 * to license@prestashop.com so we can send you a copy immediately. 15 * 16 * DISCLAIMER 17 * 18 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer 19 * versions in the future. If you wish to customize PrestaShop for your 20 * needs please refer to https://devdocs.prestashop.com/ for more information. 21 * 22 * @author PrestaShop SA and Contributors <contact@prestashop.com> 23 * @copyright Since 2007 PrestaShop SA and Contributors 24 * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) 25 */ 26 27namespace PrestaShopBundle\Form\Admin\Configure\ShopParameters\General; 28 29use PrestaShop\PrestaShop\Adapter\Configuration; 30use PrestaShop\PrestaShop\Core\Form\FormHandlerInterface; 31use Symfony\Component\Form\FormFactoryInterface; 32 33/** 34 * This class manages the data manipulated using forms 35 * in "Configure > Shop Parameters > General" page. 36 */ 37final class PreferencesFormHandler implements FormHandlerInterface 38{ 39 /** 40 * @var FormFactoryInterface 41 */ 42 private $formFactory; 43 44 /** 45 * @var PreferencesFormDataProvider 46 */ 47 private $formDataProvider; 48 49 /** 50 * @var Configuration 51 */ 52 private $configuration; 53 54 public function __construct( 55 FormFactoryInterface $formFactory, 56 PreferencesFormDataProvider $formDataProvider, 57 Configuration $configuration 58 ) { 59 $this->formFactory = $formFactory; 60 $this->formDataProvider = $formDataProvider; 61 $this->configuration = $configuration; 62 } 63 64 /** 65 * {@inheritdoc} 66 */ 67 public function getForm() 68 { 69 return $this->formFactory->createBuilder() 70 ->add('general', PreferencesType::class, [ 71 'is_ssl_enabled' => $this->configuration->getBoolean('PS_SSL_ENABLED'), 72 ]) 73 ->setData($this->formDataProvider->getData()) 74 ->getForm(); 75 } 76 77 /** 78 * {@inheritdoc} 79 */ 80 public function save(array $data) 81 { 82 return $this->formDataProvider->setData($data); 83 } 84} 85