src/AdminBundle/Admin/Document/DealerOfferAdmin.php line 10

Open in your IDE?
  1. <?php
  2. namespace AdminBundle\Admin\Document;
  3. use CoreBundle\Entity\Dealer;
  4. use AdminBundle\Admin\BaseAdmin;
  5. use Sonata\AdminBundle\Datagrid\ListMapper;
  6. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  7. class DealerOfferAdmin extends BaseAdmin
  8. {
  9.     protected $baseRouteName 'dealer_offer';
  10.     protected $baseRoutePattern 'dealer_offer_action';
  11.     protected function configureListFields(ListMapper $listMapper): void
  12.     {
  13.         $this->checkByRole(['ROLE_SUPER_ADMIN''ROLE_CONTENT_MANAGER''ROLE_DC_MANAGER']);
  14.         $dcList = [];
  15.         $dc $this->em
  16.             ->getRepository(Dealer::class)
  17.             ->findAll();
  18.         foreach ($dc as $item) {
  19.             $dcList[$item->getId()] = $item->getName();
  20.         }
  21.         $subDcList = [];
  22.         $subDc $this->em
  23.             ->getRepository(\ImporterBundle\Entity\Dealer::class)
  24.             ->findAll();
  25.         foreach ($subDc as $item) {
  26.             $subDcList[$item->getId()] = $item->getName();
  27.         }
  28.         $listMapper->addIdentifier('id')
  29.             ->add('name'null, ['label' => 'Імя інтеграції''editable' => true])
  30.             ->add('callBackUrl'null, ['label' => 'CallbackURL''editable' => true])
  31.             ->add('lastSync'null, ['label' => 'Остання сінхронізація з ДП ДІЯ'])
  32.             ->add('dealer'ChoiceType::class, [
  33.                 'label' => 'ДЦ',
  34.                 'class' => Dealer::class,
  35.                 'choices' => $dcList,
  36.                 'editable' => true
  37.             ])
  38.             ->add('_action''actions', [
  39.                 'label' => 'Действия',
  40.                 'actions' => [
  41.                     'edit' => [],
  42.                     'delete' => [],
  43.                 ]
  44.             ]);
  45.     }
  46. }