src/AdminBundle/Admin/TaskAdmin.php line 13

Open in your IDE?
  1. <?php
  2. namespace AdminBundle\Admin;
  3. use BmpGatewayBundle\Model\Lead;
  4. use Sonata\AdminBundle\Admin\AbstractAdmin;
  5. use Sonata\AdminBundle\Datagrid\DatagridMapper;
  6. use Sonata\AdminBundle\Datagrid\ListMapper;
  7. use Sonata\AdminBundle\Route\RouteCollectionInterface;
  8. use Sonata\DoctrineORMAdminBundle\Filter\ChoiceFilter;
  9. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  10. class TaskAdmin extends AbstractAdmin
  11. {
  12.     protected function configureRoutes(RouteCollectionInterface $collection): void
  13.     {
  14.         $collection->remove('create');
  15.         $collection->remove('view');
  16.         $collection->remove('edit');
  17.     }
  18.     protected function configureDatagridFilters(DatagridMapper $datagridMapper): void
  19.     {
  20.         $datagridMapper->add('id')
  21.             ->add('state',ChoiceFilter::class, ['label' => 'Статус'], [ 'choices' => [
  22.                 'Новая' => Lead::TASK_STATE_NEW,
  23.                 'Успешная' => Lead::TASK_STATE_DONE,
  24.                 'Не успешная' => Lead::TASK_STATE_FAIL,
  25.             ]])
  26.         ;
  27.     }
  28.     protected function configureListFields(ListMapper $listMapper): void
  29.     {
  30.         $listMapper->addIdentifier('id')
  31.             ->add('state'ChoiceType::class, ['label' => 'Состояние''choices' => [
  32.                 Lead::TASK_STATE_NEW => 'Новая',
  33.                 Lead::TASK_STATE_DONE => 'Успешная',
  34.                 Lead::TASK_STATE_FAIL => 'Не успешнаяа',
  35.             ]])
  36.             ->add('body',null, ['label' => 'Данные'])
  37.             ->add('referer',null, ['label' => 'Referer'])
  38.             ->add('date_create',null, ['label' => 'Дата создания''format' => 'Y-m-d H:i:s'])
  39.         ;
  40.     }
  41. }