From 4979682c712050b5ce8e469b2a610c68af1b353f Mon Sep 17 00:00:00 2001 From: Sergey Romaneko Date: Thu, 25 Oct 2012 13:04:00 +0300 Subject: [PATCH] Options API: add exist() method --- monstra/engine/options.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/monstra/engine/options.php b/monstra/engine/options.php index c68c7a5..68a8524 100644 --- a/monstra/engine/options.php +++ b/monstra/engine/options.php @@ -164,4 +164,26 @@ return Option::$options->deleteWhere('[name="'.$option.'"]'); } + + /** + * Check if option exist + * + * + * if (Option::exist('pages_limit')) { + * // do something... + * } + * + * + * @param string $option Name of option to check. + * @return boolean + */ + public static function exist($option) { + + // Redefine vars + $option = (string) $option; + + // Check if option exist + return (count(Option::$options->select('[name="'.$option.'"]', null)) > 0) ? true : false; + } + } \ No newline at end of file