Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sidgitind opened this issue Dec 21, 2018 · 0 comments
Open

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

sidgitind opened this issue Dec 21, 2018 · 0 comments

Comments

@sidgitind
Copy link

sidgitind commented Dec 21, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant