Permalink
Browse files

Merge branch 'master' of github.com:rgigger/zinc

  • Loading branch information...
2 parents b45367a + acafa59 commit 6c87eeb7f41016802e91a3f6fe82ba7782f46b0c @rgigger committed Aug 31, 2012
Showing with 61 additions and 1 deletion.
  1. +61 −1 framework/core/app/Application.php
@@ -13,5 +13,65 @@ function __construct()
// $this->init();
}
- public function init() {}
+ public function init() {}
+
+ /*
+ *
+ * name: Condition
+ * @param bool a true/false condition
+ * @param closure if !bool, then closure()
+ * @return
+ *
+ */
+ static public function Condition($bool, $closure)
+ {
+ if(!$bool)
+ $closure();
+ }
+
+ /*
+ *
+ * name: ConditionBaseRedirect
+ * @param bool
+ * @param url an application url (everything after index.php)
+ * @return
+ *
+ */
+ static public function ConditionBaseRedirect($bool, $url)
+ {
+ self::Condition($bool, function () use ($url) {
+ BaseRedirect($url);
+ });
+ }
+
+ /*
+ *
+ * name: ConditionRedirect
+ * @param bool
+ * @param url a full url
+ * @return
+ *
+ */
+ static public function ConditionRedirect($bool, $url)
+ {
+ self::Condition($bool, function () use ($url) {
+ redirect($url);
+ });
+ }
+
+ /*
+ *
+ * name: ConditionError
+ * @param bool
+ * @param errorMessage An error message to log with the error.
+ * @return
+ *
+ */
+ static public function ConditionError($bool, $errorMessage)
+ {
+ self::Condition($bool, function () use ($errorMessage) {
+ trigger_error($errorMessage);
+ die();
+ });
+ }
}

0 comments on commit 6c87eeb

Please sign in to comment.