src/Eccube/Form/Type/SearchProductType.php line 26

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of EC-CUBE
  4.  *
  5.  * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
  6.  *
  7.  * http://www.ec-cube.co.jp/
  8.  *
  9.  * For the full copyright and license information, please view the LICENSE
  10.  * file that was distributed with this source code.
  11.  */
  12. namespace Eccube\Form\Type;
  13. use Eccube\Form\Type\Master\ProductListMaxType;
  14. use Eccube\Form\Type\Master\ProductListOrderByType;
  15. use Eccube\Repository\CategoryRepository;
  16. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  17. use Symfony\Component\Form\AbstractType;
  18. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  19. use Symfony\Component\Form\Extension\Core\Type\SearchType;
  20. use Symfony\Component\Form\FormBuilderInterface;
  21. use Symfony\Component\OptionsResolver\OptionsResolver;
  22. class SearchProductType extends AbstractType
  23. {
  24.     /**
  25.      * @var CategoryRepository
  26.      */
  27.     protected $categoryRepository;
  28.     /**
  29.      * SearchProductType constructor.
  30.      *
  31.      * @param CategoryRepository $categoryRepository
  32.      */
  33.     public function __construct(CategoryRepository $categoryRepository)
  34.     {
  35.         $this->categoryRepository $categoryRepository;
  36.     }
  37.     /**
  38.      * {@inheritdoc}
  39.      */
  40.     public function buildForm(FormBuilderInterface $builder, array $options)
  41.     {
  42.         $Categories $this->categoryRepository
  43.             ->getList(nulltrue);
  44.         $builder->add('mode'HiddenType::class, [
  45.             'data' => 'search',
  46.         ]);
  47.         $builder->add('category_id'EntityType::class, [
  48.             'class' => 'Eccube\Entity\Category',
  49.             'choice_label' => 'NameWithLevel',
  50.             'choices' => $Categories,
  51.             'placeholder' => 'common.select__all_products',
  52.             'required' => false,
  53.         ]);
  54.         $builder->add('name'SearchType::class, [
  55.             'required' => false,
  56.             'attr' => [
  57.                 'maxlength' => 50,
  58.             ],
  59.         ]);
  60.         $builder->add('pageno'HiddenType::class, []);
  61.         $builder->add('disp_number'ProductListMaxType::class, [
  62.             'label' => false,
  63.         ]);
  64.         $builder->add('orderby'ProductListOrderByType::class, [
  65.             'label' => false,
  66.         ]);
  67.     }
  68.     /**
  69.      * {@inheritdoc}
  70.      */
  71.     public function configureOptions(OptionsResolver $resolver)
  72.     {
  73.         $resolver->setDefaults([
  74.             'csrf_protection' => false,
  75.             'allow_extra_fields' => true,
  76.         ]);
  77.     }
  78.     /**
  79.      * {@inheritdoc}
  80.      */
  81.     public function getBlockPrefix()
  82.     {
  83.         return 'search_product';
  84.     }
  85. }