-
Notifications
You must be signed in to change notification settings - Fork 139
Description
Looking at the examples, I realized that the rules are created and executed within a function. The variables of the rules are passed as input to the function. How can I separate the creation of Rules and Execution of rules. I want to have a set of library of Rules design for my flows and then use them in the project as per the need. This is what I am trying to do and its not working...The Rule in the Demo function is not executed.
class Test_Controller extends CI_Controller
{
public function demo()
{
echo "demo";
$rb = new RuleBuilder;
$rule = $rb->create(
$rb->logicalAnd(
$rb['minNumPeople']->lessThanOrEqualTo($rb['actualNumPeople']),
$rb['maxNumPeople']->greaterThanOrEqualTo($rb['actualNumPeople'])
),
function() {
echo 'YAY!';
}
);
}
public function test()
{
$context = new Context(array(
'minNumPeople' => 5,
'maxNumPeople' => 25,
'actualNumPeople' => function() {
return 6;
},
));
//echo "test";
$rule->execute($context);
}
}
Thanks.