src/Eccube/Form/Type/Admin/SearchPluginApiType.php line 24

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\Admin;
  13. use Eccube\Entity\Master\PageMax;
  14. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  15. use Symfony\Component\Form\AbstractType;
  16. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  17. use Symfony\Component\Form\Extension\Core\Type\SearchType;
  18. use Symfony\Component\Form\FormBuilderInterface;
  19. use Symfony\Component\OptionsResolver\OptionsResolver;
  20. class SearchPluginApiType extends AbstractType
  21. {
  22.     /**
  23.      * {@inheritdoc}
  24.      */
  25.     public function buildForm(FormBuilderInterface $builder, array $options)
  26.     {
  27.         $category $options['category'];
  28.         // Todo: constant for the API key
  29.         $priceType = [
  30.             'charge' => trans('admin.store.plugin_owners_search.form.price_type.fee'),
  31.             'free' => trans('admin.store.plugin_owners_search.form.price_type.free'),
  32.         ];
  33.         // Todo: constant for the API key
  34.         $orderBy = [
  35.             'date' => trans('admin.store.plugin_owners_search.form.sort.new'),
  36.             'price' => trans('admin.store.plugin_owners_search.form.sort.price'),
  37.             'dl' => trans('admin.store.plugin_owners_search.form.sort.dl'),
  38.         ];
  39.         $builder->add('category_id'ChoiceType::class, [
  40.             'choices' => array_flip($category),
  41.             'placeholder' => 'admin.store.plugin_owners_search.form.placeholder',
  42.             'required' => false,
  43.             'label' => 'admin.store.plugin_owners_search.form.category',
  44.         ]);
  45.         $builder->add('price_type'ChoiceType::class, [
  46.             'choices' => array_flip($priceType),
  47.             'placeholder' => 'admin.store.plugin_owners_search.form.placeholder',
  48.             'required' => false,
  49.             'label' => 'admin.store.plugin_owners_search.form.price_type',
  50.         ]);
  51.         $builder->add('keyword'SearchType::class, [
  52.             'required' => false,
  53.             'label' => 'admin.store.plugin_owners_search.form.keyword',
  54.             'attr' => [
  55.                 'maxlength' => 50,
  56.             ],
  57.         ]);
  58.         $builder->add('sort'ChoiceType::class, [
  59.             'label' => 'searchproduct.label.sort_by',
  60.             'required' => false,
  61.             'placeholder' => null,
  62.             'choices' => array_flip($orderBy),
  63.         ]);
  64.         $builder->add('page_count'EntityType::class, [
  65.             'required' => false,
  66.             'placeholder' => null,
  67.             'class' => PageMax::class,
  68.             'choice_label' => function (PageMax $pageMax) {
  69.                 return trans('admin.common.count', ['%count%' => $pageMax->getName()]);
  70.             },
  71.         ]);
  72.     }
  73.     /**
  74.      * {@inheritdoc}
  75.      */
  76.     public function configureOptions(OptionsResolver $resolver)
  77.     {
  78.         $resolver->setDefaults([
  79.             'category' => [],
  80.         ]);
  81.     }
  82.     /**
  83.      * {@inheritdoc}
  84.      */
  85.     public function getBlockPrefix()
  86.     {
  87.         return 'search_plugin';
  88.     }
  89. }