summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Cornutt <enygma@phpdeveloper.org>2015-05-29 22:06:48 -0500
committerChris Cornutt <enygma@phpdeveloper.org>2015-05-29 22:06:48 -0500
commitabc2588fa15dc5cc0d81af8e589b9e28bafb67a6 (patch)
tree35bf7eaff1ced07ca566a05c3f6c358a416d1c98
parentd1ab94645842a9ad6854f5355c70990a6cdcc601 (diff)
downloadgatekeeper-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.php13
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