Doctrine2WorkFlowActionAdmin.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. namespace WorkflowBundle\Admin;
  3. use Base\AdminBundle\Admin\BaseAdmin;
  4. use Sonata\AdminBundle\Datagrid\DatagridMapper;
  5. use Sonata\AdminBundle\Datagrid\ListMapper;
  6. use Sonata\AdminBundle\Form\FormMapper;
  7. use Sonata\AdminBundle\Show\ShowMapper;
  8. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  9. use \WorkflowBundle\Utils\DoctrineEvents;
  10. use \WorkflowBundle\Utils\WorkFlowEntityClasses;
  11. class Doctrine2WorkFlowActionAdmin extends BaseAdmin
  12. {
  13. /**
  14. * @param DatagridMapper $datagridMapper
  15. */
  16. protected function configureDatagridFilters(DatagridMapper $datagridMapper)
  17. {
  18. $datagridMapper
  19. ->add('name')
  20. ->add('eventName')
  21. ->add('entityClass')
  22. ;
  23. }
  24. /**
  25. * @param ListMapper $listMapper
  26. */
  27. protected function configureListFields(ListMapper $listMapper)
  28. {
  29. $listMapper
  30. ->add('name')
  31. ->add('eventName')
  32. ->add('entityClass')
  33. ->add('actions')
  34. ->add('_action', null, array(
  35. 'actions' => array(
  36. 'show' => array(),
  37. 'edit' => array(),
  38. 'delete' => array(),
  39. )
  40. ))
  41. ;
  42. }
  43. /**
  44. * @param FormMapper $formMapper
  45. */
  46. protected function configureFormFields(FormMapper $formMapper)
  47. {
  48. $formMapper
  49. ->add('name')
  50. ->add('eventName', ChoiceType::class, array(
  51. 'choices' => DoctrineEvents::getDoctrineEventChoices(),
  52. ))
  53. ->add('entityClass', ChoiceType::class, array(
  54. 'choices' => WorkFlowEntityClasses::getChoices(),
  55. ))
  56. ->add('actions', null, array(
  57. 'multiple' => true,
  58. 'expanded' => true,
  59. 'by_reference' => false
  60. ))
  61. ;
  62. }
  63. /**
  64. * @param ShowMapper $showMapper
  65. */
  66. protected function configureShowFields(ShowMapper $showMapper)
  67. {
  68. $showMapper
  69. ->add('name')
  70. ->add('eventName')
  71. ->add('entityClass')
  72. ->add('actions')
  73. ;
  74. }
  75. }