diff options
author | Chris Cornutt <enygma@phpdeveloper.org> | 2015-05-29 22:06:48 -0500 |
---|---|---|
committer | Chris Cornutt <enygma@phpdeveloper.org> | 2015-05-29 22:06:48 -0500 |
commit | abc2588fa15dc5cc0d81af8e589b9e28bafb67a6 (patch) | |
tree | 35bf7eaff1ced07ca566a05c3f6c358a416d1c98 | |
parent | d1ab94645842a9ad6854f5355c70990a6cdcc601 (diff) | |
download | gatekeeper-abc2588fa15dc5cc0d81af8e589b9e28bafb67a6.zip gatekeeper-abc2588fa15dc5cc0d81af8e589b9e28bafb67a6.tar.gz gatekeeper-abc2588fa15dc5cc0d81af8e589b9e28bafb67a6.tar.bz2 |
adding the evaluatePolicy method to check data against a given policy
-rw-r--r-- | src/Psecio/Gatekeeper/Gatekeeper.php | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/Psecio/Gatekeeper/Gatekeeper.php b/src/Psecio/Gatekeeper/Gatekeeper.php index e39519f..80f112b 100644 --- a/src/Psecio/Gatekeeper/Gatekeeper.php +++ b/src/Psecio/Gatekeeper/Gatekeeper.php @@ -578,4 +578,17 @@ class Gatekeeper $remember = new Session\RememberMe(self::$datasource, $_COOKIE); return $remember->verify(); } + + /** + * Evaluate the policy (found by name) against the data provided + * + * @param string $name Name of the policy + * @param mixed $data Data to use in evaluation (single object or array) + * @return boolean Pass/fail status of evaluation + */ + public static function evaluatePolicy($name, $data) + { + $policy = Gatekeeper::findPolicyByName($name); + return $policy->evaluate($data, $policy->expression); + } }
\ No newline at end of file |