app/Plugin/CustomerRank42/Form/Extension/AdminCustomerExtension.php line 36

Open in your IDE?
  1. <?php
  2. /*
  3. * Plugin Name : CustomerRank
  4. *
  5. * Copyright (C) BraTech Co., Ltd. All Rights Reserved.
  6. * http://www.bratech.co.jp/
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace Plugin\CustomerRank42\Form\Extension;
  12. use Doctrine\ORM\EntityRepository;
  13. use Eccube\Form\Type\Admin\CustomerType;
  14. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  15. use Symfony\Component\Form\AbstractTypeExtension;
  16. use Symfony\Component\Form\FormBuilderInterface;
  17. class AdminCustomerExtension extends AbstractTypeExtension
  18. {
  19.     public function buildForm(FormBuilderInterface $builder, array $options)
  20.     {
  21.         $builder
  22.             ->add(
  23.                 'CustomerRank',
  24.                 EntityType::class,
  25.                 [
  26.                     'label' => trans('customerrank.common.rank'),
  27.                     'class' => 'Plugin\CustomerRank42\Entity\CustomerRank',
  28.                     'multiple' => false,
  29.                     'expanded' => false,
  30.                     'required' => false,
  31.                     'placeholder' => trans('customerrank.admin.common.nothing'),
  32.                     'query_builder' => function (EntityRepository $er) {
  33.                         return $er->createQueryBuilder('cr')
  34.                             ->orderBy('cr.priority''DESC');
  35.                     },
  36.                 ]
  37.             );
  38.     }
  39.     public static function getExtendedTypes(): iterable
  40.     {
  41.         return [CustomerType::class];
  42.     }
  43. }