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.
 
 
 
 
 

214 lines
3.8 KiB

<?php
namespace Zitec\RuleEngineBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Zitec\RuleEngineBundle\DoctrineBehaviors\RuleInterface;
use Zitec\RuleEngineBundle\Form\RuleObject;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Class Rule
*
* @package RuleEngineBundle\Entity
*/
class Rule
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="string", nullable=true)
* @Assert\NotBlank()
* @Assert\Length(max = 100)
*/
protected $name = '';
/**
* @ORM\Column(type="boolean", nullable=true, options={"default": 1})
*/
protected $active=1;
/**
* @ORM\Column(type="text", nullable=true)
*/
protected $expression = '';
/**
* @ORM\Column(type="text", nullable=true)
*/
protected $json = '';
/**
* @var RuleObject
*/
protected $ruleObject = null;
/**
* @ORM\Column(type="text", nullable=true)
*/
protected $action = '';
/**
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @param null|string $name
*/
public function setName(?string $name)
{
$this->name = $name;
}
/**
* Set active
*
* @param boolean $active
*
* @return Rule
*/
public function setActive($active)
{
$this->active = ($active)?1:0;
return $this;
}
/**
* Get active
*
* @return boolean
*/
public function getActive()
{
return ($this->active)?true:false;
}
/**
* Returns expression in expression language format
* @return string
*/
public function getExpression()
{
return $this->expression;
}
/**
* @param null|string $expression
* @return Rule
*/
public function setExpression(?string $expression)
{
$this->expression = $expression;
return $this;
}
/**
* @return string
*/
public function getJson()
{
return $this->json;
}
/**
* @param null|string $json
* @return Rule
*/
public function setJson(?string $json)
{
$this->json = $json;
return $this;
}
/**
* Set the object that contains expression language and json
* @param RuleObject $ruleObject
* @return $this
*/
public function setRuleObject(RuleObject $ruleObject)
{
if ($ruleObject) {
$this->ruleObject = $ruleObject;
$this->json = $ruleObject->getJson();
$this->expression = $ruleObject->getExpression();
}
return $this;
}
/**
* Returns the rule object
* @return null|RuleObject
*/
public function getRuleObject()
{
if (is_null($this->ruleObject)) {
$this->ruleObject = new RuleObject();
$this->ruleObject->setExpression($this->expression);
$this->ruleObject->setJson($this->json);
}
return $this->ruleObject;
}
/**
* @return string
*/
public function getAction()
{
return $this->action;
}
/**
* @param string $action
*/
public function setAction( $action): void
{
$this->action = $action;
}
/**
* @return string
*/
public function getActions()
{
return $this->action;
}
/**
* @param string $action
*/
public function setActions( $action): void
{
$this->action = $action;
}
/**
* @return string
*/
public function __toString()
{
if ($this->name) {
return $this->name;
}
return '';
}
}