src/AdminBundle/Admin/TxnAdmin.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 TxnAdmin extends AbstractAdmin
  11. {
  12.     protected $datagridValues = [
  13.         '_page'       => 1,
  14.         '_sort_order' => 'DESC'// sort direction
  15.         '_sort_by' => 'id' // field name
  16.     ];
  17.     protected function configureRoutes(RouteCollectionInterface $collection): void
  18.     {
  19.         $collection->remove('create');
  20.         $collection->remove('view');
  21.         $collection->remove('edit');
  22.     }
  23.     protected function configureDatagridFilters(DatagridMapper $datagridMapper): void
  24.     {
  25.         $datagridMapper->add('id')
  26.             ->add('task'null, ['label' => 'Задача'])
  27.             ->add('date_create'null, ['label' => 'Дата создания'], null, ['attr' => ['class' => 'js-date-picker']])
  28.             ->add('state',ChoiceFilter::class, ['label' => 'Статус'], [ 'choices' => [
  29.                 'Новая' => Lead::TXN_STATE_NEW,
  30.                 'Успешная' => Lead::TXN_STATE_SUCCESS,
  31.                 'Не успешная' => Lead::TXN_STATE_FAIL,
  32.             ]])
  33.         ;
  34.     }
  35.     protected function configureListFields(ListMapper $listMapper): void
  36.     {
  37.         $listMapper->addIdentifier('id')
  38.             ->add('state'ChoiceType::class, ['label' => 'Состояние''choices' => [
  39.                 Lead::TXN_STATE_NEW => 'Новая',
  40.                 Lead::TXN_STATE_SUCCESS => 'Успешная',
  41.                 Lead::TXN_STATE_FAIL => 'Не успешнаяа',
  42.             ]])
  43.             ->add('params',null, ['label' => 'Данные'])
  44.             ->add('response',null, ['label' => 'Ответ'])
  45.             ->add('date_create',null, ['label' => 'Дата создания''format' => 'Y-m-d H:i:s'])
  46.             ->add('task',null, ['label' => 'Задача'])
  47.         ;
  48.     }
  49. }