<?php
namespace AdminBundle\Admin\Document;
use CoreBundle\Entity\Dealer;
use AdminBundle\Admin\BaseAdmin;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
class DealerOfferAdmin extends BaseAdmin
{
protected $baseRouteName = 'dealer_offer';
protected $baseRoutePattern = 'dealer_offer_action';
protected function configureListFields(ListMapper $listMapper): void
{
$this->checkByRole(['ROLE_SUPER_ADMIN', 'ROLE_CONTENT_MANAGER', 'ROLE_DC_MANAGER']);
$dcList = [];
$dc = $this->em
->getRepository(Dealer::class)
->findAll();
foreach ($dc as $item) {
$dcList[$item->getId()] = $item->getName();
}
$subDcList = [];
$subDc = $this->em
->getRepository(\ImporterBundle\Entity\Dealer::class)
->findAll();
foreach ($subDc as $item) {
$subDcList[$item->getId()] = $item->getName();
}
$listMapper->addIdentifier('id')
->add('name', null, ['label' => 'Імя інтеграції', 'editable' => true])
->add('callBackUrl', null, ['label' => 'CallbackURL', 'editable' => true])
->add('lastSync', null, ['label' => 'Остання сінхронізація з ДП ДІЯ'])
->add('dealer', ChoiceType::class, [
'label' => 'ДЦ',
'class' => Dealer::class,
'choices' => $dcList,
'editable' => true
])
->add('_action', 'actions', [
'label' => 'Действия',
'actions' => [
'edit' => [],
'delete' => [],
]
]);
}
}