You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
2.0KB

  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. }