src/Infraestructure/Admin/EstadoAdmin.php line 15

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Infraestructure\Admin;
  4. use App\Domain\Entity\EstadoExpediente;
  5. use App\Domain\Repository\EstadoRepositoryInterface;
  6. use Sonata\AdminBundle\Datagrid\ListMapper;
  7. use Sonata\AdminBundle\Form\FormMapper;
  8. use Sonata\AdminBundle\Show\ShowMapper;
  9. class EstadoAdmin extends FilterAbstractAdmin
  10. {
  11.     public function __construct(
  12.         $code,
  13.         $class,
  14.         $baseControllerName,
  15.         protected EstadoRepositoryInterface $estadoRepository,
  16.     )
  17.     {
  18.         parent::__construct($code$class$baseControllerName$this->estadoRepository);
  19.     }
  20.     protected function configureListFields(ListMapper $list): void
  21.     {
  22.         $this->setTranslationDomain('estadoAdmin');
  23.         $list
  24.             ->add('key'null, [
  25.                 'label' => 'list.estado.label.key'
  26.             ])
  27.             ->add('nombre'null, [
  28.                 'label' => 'list.estado.label.nombre'
  29.             ])
  30.             ->add('color'null, [
  31.                 'label' => 'list.estado.label.color'
  32.             ])
  33.             ->add('icono'null, [
  34.                 'label' => 'list.estado.label.icono'
  35.             ])
  36.             ->add('orden'null, [
  37.                 'label' => 'list.estado.label.orden'
  38.             ])
  39.             ->add(ListMapper::NAME_ACTIONSnull, [
  40.                 'label' => false,
  41.                 'actions' => [
  42.                     'edit' => [],
  43.                     'delete' => [],
  44.                 ],
  45.                 'header_style' => 'width: 85px',
  46.             ])
  47.         ;
  48.     }
  49.     protected function configureFormFields(FormMapper $form): void
  50.     {
  51.         $form
  52.             ->add('key'null, [
  53.                 'label' => 'form.estado.label.key'
  54.             ])
  55.             ->add('nombre'null, [
  56.                 'label' => 'form.estado.label.nombre'
  57.             ])
  58.         ;
  59.         if($this->getSubject() instanceof EstadoExpediente) {
  60.             $form
  61.                 ->add('subestado'null, [
  62.                     'label' => 'form.estado.label.subestado'
  63.                 ]);
  64.         }
  65.         $form
  66.             ->add('color'null, [
  67.                 'label' => 'form.estado.label.color'
  68.             ])
  69.             ->add('icono'null, [
  70.                 'label' => 'form.estado.label.icono'
  71.             ])
  72.             ->add('orden'null, [
  73.                 'label' => 'form.estado.label.orden'
  74.             ])
  75.             ->add('descripcion'null, [
  76.                 'label' => 'form.estado.label.descripcion'
  77.             ])
  78.         ;
  79.     }
  80.     protected function configureShowFields(ShowMapper $show): void
  81.     {
  82.     }
  83. }