Licitator 1.0
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.7 KiB

5 years ago
  1. <?php
  2. namespace Zitec\RuleEngineBundle\Admin;
  3. use Zitec\RuleEngineBundle\Form\Type\RuleEngineType;
  4. use Sonata\AdminBundle\Admin\AbstractAdmin;
  5. use Sonata\AdminBundle\Datagrid\ListMapper;
  6. use Sonata\AdminBundle\Form\FormMapper;
  7. /**
  8. * Class RuleAdmin
  9. */
  10. class RuleAdmin extends AbstractAdmin
  11. {
  12. /**
  13. * @param FormMapper $formMapper
  14. */
  15. protected function configureFormFields(FormMapper $formMapper)
  16. {
  17. $fieldOptions = ['label' => false];
  18. $parentOptions = $this->getParentFieldDescription()->getOptions();
  19. if (!isset($parentOptions['rule_manager'])) {
  20. throw new \RuntimeException('Missing rule manager object!');
  21. }
  22. $fieldOptions['rule_manager'] = $parentOptions['rule_manager'];
  23. $formMapper
  24. ->with('General', ['class' => 'col-md-12'])
  25. ->add('active')
  26. ->add('name')
  27. ->end()
  28. ->with('Reglas', ['class' => 'col-md-12'])
  29. ->add('ruleObject', RuleEngineType::class, $fieldOptions)
  30. ->end()
  31. ->with('Acciones', [
  32. 'class' => 'col-md-12',
  33. 'box_class' => 'box box-solid box-success custom-form-fields',
  34. 'description' => 'Acciones a realizar',
  35. ])
  36. ->add('action','hidden',array('attr'=>array("hidden" => true)))
  37. ->end()
  38. ->end();
  39. }
  40. /**
  41. * @param ListMapper $list
  42. */
  43. protected function configureListFields(ListMapper $list)
  44. {
  45. $list->add('expression')
  46. ->add('json')
  47. ->add('action')
  48. ->add('_action', null, ['actions' => ['edit' => [], 'delete' => []]]);
  49. }
  50. }