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\Sell\Category; 28 29use PrestaShop\PrestaShop\Core\Domain\Category\ValueObject\CategoryDeleteMode; 30use Symfony\Component\Form\AbstractType; 31use Symfony\Component\Form\Extension\Core\Type\ChoiceType; 32use Symfony\Component\Form\Extension\Core\Type\CollectionType; 33use Symfony\Component\Form\Extension\Core\Type\HiddenType; 34use Symfony\Component\Form\FormBuilderInterface; 35 36/** 37 * Class DeleteCategoriesType. 38 */ 39class DeleteCategoriesType extends AbstractType 40{ 41 /** 42 * @var array 43 */ 44 private $categoryDeleteModelChoices; 45 46 /** 47 * @param array $categoryDeleteModelChoices 48 */ 49 public function __construct(array $categoryDeleteModelChoices) 50 { 51 $this->categoryDeleteModelChoices = $categoryDeleteModelChoices; 52 } 53 54 /** 55 * {@inheritdoc} 56 */ 57 public function buildForm(FormBuilderInterface $builder, array $options) 58 { 59 $builder 60 ->add('delete_mode', ChoiceType::class, [ 61 'expanded' => true, 62 'choices' => $this->categoryDeleteModelChoices, 63 'label' => false, 64 'data' => CategoryDeleteMode::ASSOCIATE_PRODUCTS_WITH_PARENT_AND_DISABLE, 65 ]) 66 ->add('categories_to_delete', CollectionType::class, [ 67 'entry_type' => HiddenType::class, 68 'label' => false, 69 'allow_add' => true, 70 ]) 71 ->add('categories_to_delete_parent', HiddenType::class, [ 72 'label' => false, 73 ]); 74 } 75} 76