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 PrestaShop\PrestaShop\Core\Form\ChoiceProvider; 28 29use PrestaShop\PrestaShop\Core\Domain\Category\ValueObject\CategoryDeleteMode; 30use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; 31use Symfony\Component\Translation\TranslatorInterface; 32 33/** 34 * Class CategoryDeleteModeChoiceProvider. 35 */ 36final class CategoryDeleteModeChoiceProvider implements FormChoiceProviderInterface 37{ 38 /** 39 * @var TranslatorInterface 40 */ 41 private $translator; 42 43 /** 44 * @param TranslatorInterface $translator 45 */ 46 public function __construct(TranslatorInterface $translator) 47 { 48 $this->translator = $translator; 49 } 50 51 /** 52 * {@inheritdoc} 53 */ 54 public function getChoices() 55 { 56 $associateOnlyLabel = $this->translator->trans( 57 'If they have no other category, I want to associate them with the parent category.', 58 [], 59 'Admin.Catalog.Notification' 60 ); 61 62 $associateAndDisableLabel = sprintf( 63 '%s %s', 64 $this->translator->trans( 65 'If they have no other category, I want to associate them with the parent category and turn them offline.', 66 [], 67 'Admin.Catalog.Notification' 68 ), 69 $this->translator->trans('(Recommended)', [], 'Admin.Catalog.Notification') 70 ); 71 72 $deleteProductLabel = $this->translator->trans( 73 'If they have no other category, I want to delete them as well.', 74 [], 75 'Admin.Catalog.Notification' 76 ); 77 78 return [ 79 $associateAndDisableLabel => CategoryDeleteMode::ASSOCIATE_PRODUCTS_WITH_PARENT_AND_DISABLE, 80 $associateOnlyLabel => CategoryDeleteMode::ASSOCIATE_PRODUCTS_WITH_PARENT_ONLY, 81 $deleteProductLabel => CategoryDeleteMode::REMOVE_ASSOCIATED_PRODUCTS, 82 ]; 83 } 84} 85