Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

MerchantAdminController.php 2.0KB

před 3 roky
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace Lc\CaracoleBundle\Controller\Merchant;
  3. use App\Entity\Merchant\Merchant;
  4. use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
  5. use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
  6. use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
  7. use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
  8. use Lc\CaracoleBundle\Container\Merchant\MerchantContainer;
  9. use Lc\CaracoleBundle\Controller\AdminControllerTrait;
  10. use Lc\CaracoleBundle\Factory\Merchant\MerchantFactory;
  11. use Lc\CaracoleBundle\Field\Address\AddressField;
  12. use Lc\SovBundle\Controller\AbstractAdminController;
  13. use Lc\SovBundle\Field\CKEditorField;
  14. use Lc\SovBundle\Field\StatusField;
  15. use Lc\SovBundle\Repository\RepositoryQueryInterface;
  16. abstract class MerchantAdminController extends AbstractAdminController
  17. {
  18. use AdminControllerTrait;
  19. public function getRepositoryQuery() :RepositoryQueryInterface
  20. {
  21. return $this->get(MerchantContainer::class)->getRepositoryQuery();
  22. }
  23. public function configureFields(string $pageName): iterable
  24. {
  25. $panel = parent::configureFields($pageName);
  26. return array_merge(
  27. [
  28. FormField::addPanel('general'),
  29. TextField::new('title'),
  30. NumberField::new('position')
  31. ->hideOnForm()
  32. ->hideOnIndex(),
  33. CKEditorField::new('description')
  34. ->hideOnIndex(),
  35. AssociationField::new('taxRate')
  36. ->setRequired(true)
  37. ->hideOnIndex(),
  38. StatusField::new('status'),
  39. FormField::addPanel('address'),
  40. AddressField::new('address')
  41. ->setRequired(true),
  42. ],
  43. $panel
  44. );
  45. }
  46. public function createEntity(string $entityFqcn)
  47. {
  48. return $this->get(MerchantContainer::class)->getFactory()->create();
  49. }
  50. }