dev-master
9999999-devReusable library
MIT
The Requires
The Development Requires
by Martin Poirier ThĂ©orĂȘt
library bundle symfony specification nucleus business-rule-engine
Wallogit.com
2017 © Pedro PelĂĄez
Reusable library
Integration of the BusinessRuleEngine as a Symfony bundle., (*2)
You should read the Business Rule Engine documentation to know how and why to use it. The current documentation is meant to explain and to enable it and configure it in symfony., (*3)
<?php // in AppKernel::registerBundles() $bundles = array( // ... new Nucleus\Bundle\BusinessRuleEngineBundle\NucleusBusinessRuleEngineBundle(), // ... );
From there you can use the BusinessRuleEngine., (*4)
The service is named nucleus.business_rule_engine so you can access it via the service container like this:, (*5)
<?php $businessRuleEngine = $serviceContainer->get('nucleus.business_rule_engine');
Or injecting it in your service. Be sure to use the interface Nucleus\BusinessRuleEngine\IBusinessRuleEngine when you are referencing the object., (*6)
To add a service as a rule you need to tag the specific service., (*7)
<service id="my_namespace.my_module.my_service" class="MyNamespace\MyModule\MyServiceClass"> <tag name="nucleus.business_rule_engine.rule" ruleName="myRuleName" /> </service>
The example is in xml, refer to symfony doc to know how to tag in YML or PHP., (*8)
The tag named nucleus.business_rule_engine.rule is use by this bundle to know witch service are a rule. The attribute ruleName will be the one you must refer when calling the business rule engine., (*9)
Since the BusinessRuleEngine is expecting a callable to be a rule, be sure to implement the __invoke magic method in php on your service., (*10)
<?php namespace MyNamespace\MyModule; class MyServiceClass { /* ... */ public function __invoke($toto) { /* ... do processing ... */ return $result;//The business rule engine expect to receive a boolean value in return } }
In the bundle we are implementing a IRuleProvider that is ContainerAware so service will not be loaded until you call a rule., (*11)
documentation for the integration in symfony, (*12)
Reusable library
MIT
library bundle symfony specification nucleus business-rule-engine