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.
 
 
 
 
 

42 lines
1.3 KiB

<?php
namespace Zitec\RuleEngineBundle\Admin;
use Zitec\RuleEngineBundle\DoctrineBehaviors\PreconditionInterface;
use Zitec\RuleEngineBundle\DoctrineBehaviors\RuleInterface;
use Zitec\RuleEngineBundle\Service\RuleConditionsManager;
use Zitec\RuleEngineBundle\Service\RuleJsonConverter;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Form\Type\AdminType;
trait AbstractRuleTrait
{
/**
* Set the form theme to include the RuleEngine field template.
*
* @return array
*/
public function getFormTheme()
{
return array_merge(parent::getFormTheme(), [
'ZitecRuleEngineBundle:Form:precondition_engine.html.twig',
'ZitecRuleEngineBundle:Form:postcondition_engine.html.twig'
]);
}
/**
* Returns the rule manager service instance for the given entity.
*
* @param RuleInterface|null $entity
* @return RuleConditionsManager
*/
protected function getRuleManager(RuleInterface $entity = null): RuleConditionsManager
{
$entity = $entity ?? $this->getSubject();
return $this->getConfigurationPool()->getContainer()
->get('rule_engine.orchestrator')->getConditionsManagerForEntity($entity);
}
}