src/AdminBundle/Admin/TaskAdmin.php line 12

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 Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  9. class TaskAdmin extends AbstractAdmin
  10. {
  11.     protected function configureRoutes(RouteCollectionInterface $collection): void
  12.     {
  13.         $collection->remove('create');
  14.         $collection->remove('view');
  15.         $collection->remove('edit');
  16.     }
  17.     protected function configureDatagridFilters(DatagridMapper $datagridMapper): void
  18.     {
  19.         $datagridMapper->add('id')
  20.             ->add('state',null, ['label' => 'Статус'], ChoiceType::class, [ 'choices' => [
  21.                 'Новая' => Lead::TASK_STATE_NEW,
  22.                 'Успешная' => Lead::TASK_STATE_DONE,
  23.                 'Не успешная' => Lead::TASK_STATE_FAIL,
  24.             ]])
  25.         ;
  26.     }
  27.     protected function configureListFields(ListMapper $listMapper): void
  28.     {
  29.         $listMapper->addIdentifier('id')
  30.             ->add('state'ChoiceType::class, ['label' => 'Состояние''choices' => [
  31.                 Lead::TASK_STATE_NEW => 'Новая',
  32.                 Lead::TASK_STATE_DONE => 'Успешная',
  33.                 Lead::TASK_STATE_FAIL => 'Не успешнаяа',
  34.             ]])
  35.             ->add('body',null, ['label' => 'Данные'])
  36.             ->add('referer',null, ['label' => 'Referer'])
  37.             ->add('date_create',null, ['label' => 'Дата создания''format' => 'Y-m-d H:i:s'])
  38.         ;
  39.     }
  40. }