src/Eccube/Form/Type/Admin/PluginManagementType.php line 23

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 Symfony\Component\Form\AbstractType;
  14. use Symfony\Component\Form\Extension\Core\Type\FileType;
  15. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  16. use Symfony\Component\Form\FormBuilderInterface;
  17. use Symfony\Component\OptionsResolver\OptionsResolver;
  18. use Symfony\Component\Validator\Constraints as Assert;
  19. class PluginManagementType extends AbstractType
  20. {
  21.     public function __construct()
  22.     {
  23.     }
  24.     /**
  25.      * {@inheritdoc}
  26.      */
  27.     public function buildForm(FormBuilderInterface $builder, array $options)
  28.     {
  29.         $plugin_id $options['plugin_id'];
  30.         $builder
  31.             ->add('plugin_id'HiddenType::class, [
  32.                 'data' => $plugin_id,
  33.                 'constraints' => [
  34.                     new Assert\NotBlank(),
  35.                 ],
  36.             ])
  37.             ->add('plugin_archive'FileType::class, [
  38.                 'label' => false,
  39.                 'mapped' => false,
  40.                 'required' => false,
  41.                 'constraints' => [
  42.                     new Assert\NotBlank(['message' => 'ファイルを選択してください。']),
  43.                     new Assert\File([
  44.                         'mimeTypes' => ['application/zip''application/x-tar''application/x-gzip''application/gzip'],
  45.                         'mimeTypesMessage' => 'zipファイル、tarファイル、tar.gzファイルのいずれかをアップロードしてください。',
  46.                     ]),
  47.                 ],
  48.             ]);
  49.     }
  50.     /**
  51.      * {@inheritdoc}
  52.      */
  53.     public function getBlockPrefix()
  54.     {
  55.         return 'plugin_management';
  56.     }
  57.     /**
  58.      * {@inheritdoc}
  59.      */
  60.     public function configureOptions(OptionsResolver $resolver)
  61.     {
  62.         $resolver->setRequired(['plugin_id']);
  63.     }
  64. }