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.

41 lines
1.3 KiB

5 years ago
  1. <?php
  2. namespace Zitec\RuleEngineBundle\Admin;
  3. use Zitec\RuleEngineBundle\DoctrineBehaviors\PreconditionInterface;
  4. use Zitec\RuleEngineBundle\DoctrineBehaviors\RuleInterface;
  5. use Zitec\RuleEngineBundle\Service\RuleConditionsManager;
  6. use Zitec\RuleEngineBundle\Service\RuleJsonConverter;
  7. use Sonata\AdminBundle\Datagrid\ListMapper;
  8. use Sonata\AdminBundle\Form\FormMapper;
  9. use Sonata\AdminBundle\Form\Type\AdminType;
  10. trait AbstractRuleTrait
  11. {
  12. /**
  13. * Set the form theme to include the RuleEngine field template.
  14. *
  15. * @return array
  16. */
  17. public function getFormTheme()
  18. {
  19. return array_merge(parent::getFormTheme(), [
  20. 'ZitecRuleEngineBundle:Form:precondition_engine.html.twig',
  21. 'ZitecRuleEngineBundle:Form:postcondition_engine.html.twig'
  22. ]);
  23. }
  24. /**
  25. * Returns the rule manager service instance for the given entity.
  26. *
  27. * @param RuleInterface|null $entity
  28. * @return RuleConditionsManager
  29. */
  30. protected function getRuleManager(RuleInterface $entity = null): RuleConditionsManager
  31. {
  32. $entity = $entity ?? $this->getSubject();
  33. return $this->getConfigurationPool()->getContainer()
  34. ->get('rule_engine.orchestrator')->getConditionsManagerForEntity($entity);
  35. }
  36. }