123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- <?php
- namespace WorkflowBundle\Admin;
- use Base\AdminBundle\Admin\BaseAdmin;
- use Sonata\AdminBundle\Datagrid\DatagridMapper;
- use Sonata\AdminBundle\Datagrid\ListMapper;
- use Sonata\AdminBundle\Form\FormMapper;
- use Sonata\AdminBundle\Show\ShowMapper;
- use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
- use Symfony\Component\Form\Extension\Core\Type\TextType;
- use WorkflowBundle\Utils\WorkFlowEntityClasses;
- use WorkflowBundle\Utils\WorkFlowEvents;
- use WorkflowBundle\Utils\DoctrineEvents;
- class ActionAdmin extends BaseAdmin
- {
- public function getTemplate($name)
- {
- switch ($name) {
- case 'edit':
- return 'WorkflowBundle:Action:action_edit.html.twig';
- break;
- default:
- return parent::getTemplate($name);
- break;
- }
- }
- /**
- * @param DatagridMapper $datagridMapper
- */
- protected function configureDatagridFilters(DatagridMapper $datagridMapper)
- {
- $datagridMapper
- ->add('name')
- ->add('workflowName')
- ->add('objectClass')
- ->add('event')
- ;
- }
- /**
- * @param ListMapper $listMapper
- */
- protected function configureListFields(ListMapper $listMapper)
- {
- $listMapper
- ->add('name')
- ->add('workflowName')
- ->add('objectClass')
- ->add('event', 'html', array(
- 'template' => 'BaseAdminBundle:Utils:badge_field.html.twig',
- ))
- ->add('eventReference')
- ->add('_action', null, array(
- 'actions' => array(
- 'show' => array(),
- 'edit' => array(),
- 'delete' => array(),
- )
- ))
- ;
- }
- /**
- * @param FormMapper $formMapper
- */
- protected function configureFormFields(FormMapper $formMapper)
- {
- $formMapper
- ->add('name')
- ->add('event', ChoiceType::class, array(
- 'choices' => array(
- 'WorkFlow' => WorkFlowEvents::getChoices(),
- 'Doctrine' => DoctrineEvents::getDoctrineEventChoices(),
- ),
- 'required' => false,
- 'multiple' => true,
- )
- )
- ->add('workflowName', TextType::class, array(
- 'required' => false,
- ))
- ->add('eventReference', TextType::class, array(
- 'required' => false,
- ))
- ->add('objectClass', ChoiceType::class, array(
- 'choices' => array_filter(WorkFlowEntityClasses::getChoices(), 'class_exists'),
- 'required' => false,
- )
- )
- ->add('template', null, array(
- 'attr' => array(
- 'style' => 'height:500px;',
- ),
- )
- )
- ->setHelps(array(
- 'workflowName' => $this->trans("helps.action_label_workflow_name"),
- 'name' => $this->trans("helps.action_label_name"),
- 'objectClass' => $this->trans("helps.action_label_object_class"),
- 'event' => $this->trans("helps.action_label_event"),
- 'eventReference' => $this->trans("helps.action_label_event_reference"),
- 'template' => $this->trans("helps.action_label_template"),
- )
- )
- ;
- }
- /**
- * @param ShowMapper $showMapper
- */
- protected function configureShowFields(ShowMapper $showMapper)
- {
- $showMapper
- ->add('id')
- ->add('name')
- ->add('workflowName')
- ->add('objectClass')
- ->add('event', 'string', array(
- 'template' => 'BaseAdminBundle:Utils:badge_field.html.twig',
- ))
- ->add('eventReference')
- ->add('template','string', array(
- 'template' => 'WorkflowBundle:Action:show_template.html.twig',
- ))
- ;
- $this->parameters = array(
- 'template_type' => 'show',
- );
- }
- }
|