Skip to content

Create a Set of Rules and use it within the project #60

@sidgitind

Description

@sidgitind

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions