<?php
namespace AdminBundle\Admin;
use BmpGatewayBundle\Model\Lead;
use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Route\RouteCollectionInterface;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
class TaskAdmin extends AbstractAdmin
{
protected function configureRoutes(RouteCollectionInterface $collection): void
{
$collection->remove('create');
$collection->remove('view');
$collection->remove('edit');
}
protected function configureDatagridFilters(DatagridMapper $datagridMapper): void
{
$datagridMapper->add('id')
->add('state',null, ['label' => 'Статус'], ChoiceType::class, [ 'choices' => [
'Новая' => Lead::TASK_STATE_NEW,
'Успешная' => Lead::TASK_STATE_DONE,
'Не успешная' => Lead::TASK_STATE_FAIL,
]])
;
}
protected function configureListFields(ListMapper $listMapper): void
{
$listMapper->addIdentifier('id')
->add('state', ChoiceType::class, ['label' => 'Состояние', 'choices' => [
Lead::TASK_STATE_NEW => 'Новая',
Lead::TASK_STATE_DONE => 'Успешная',
Lead::TASK_STATE_FAIL => 'Не успешнаяа',
]])
->add('body',null, ['label' => 'Данные'])
->add('referer',null, ['label' => 'Referer'])
->add('date_create',null, ['label' => 'Дата создания', 'format' => 'Y-m-d H:i:s'])
;
}
}