diff --git a/library/Icinga/Web/Form/Validator/ReadablePathValidator.php b/library/Icinga/Web/Form/Validator/ReadablePathValidator.php index 6c32e1595..87b844fde 100644 --- a/library/Icinga/Web/Form/Validator/ReadablePathValidator.php +++ b/library/Icinga/Web/Form/Validator/ReadablePathValidator.php @@ -13,6 +13,9 @@ use Zend_Validate_Abstract; */ class ReadablePathValidator extends Zend_Validate_Abstract { + const NOT_READABLE = 'notReadable'; + const DOES_NOT_EXIST = 'doesNotExist'; + /** * The messages to write on different error states * @@ -20,18 +23,10 @@ class ReadablePathValidator extends Zend_Validate_Abstract * * @see Zend_Validate_Abstract::$_messageTemplates‚ */ - protected $_messageTemplates; - - /** - * Initialize this validator - */ - public function __construct() - { - $this->_messageTemplates = array( - 'NOT_READABLE' => t('Path is not readable'), - 'DOES_NOT_EXIST' => t('Path does not exist') - ); - } + protected $_messageTemplates = array( + self::NOT_READABLE => 'Path is not readable', + self::DOES_NOT_EXIST => 'Path does not exist' + ); /** * Check whether the given value is a readable filepath @@ -44,12 +39,13 @@ class ReadablePathValidator extends Zend_Validate_Abstract public function isValid($value, $context = null) { if (false === file_exists($value)) { - $this->_error('DOES_NOT_EXIST'); + $this->_error(self::DOES_NOT_EXIST); return false; } if (false === is_readable($value)) { - $this->_error('NOT_READABLE'); + $this->_error(self::NOT_READABLE); + return false; } return true; diff --git a/library/Icinga/Web/Form/Validator/WritablePathValidator.php b/library/Icinga/Web/Form/Validator/WritablePathValidator.php index 9620b5d7c..90b07543c 100644 --- a/library/Icinga/Web/Form/Validator/WritablePathValidator.php +++ b/library/Icinga/Web/Form/Validator/WritablePathValidator.php @@ -10,6 +10,9 @@ use Zend_Validate_Abstract; */ class WritablePathValidator extends Zend_Validate_Abstract { + const NOT_WRITABLE = 'notWritable'; + const DOES_NOT_EXIST = 'doesNotExist'; + /** * The messages to write on differen error states * @@ -18,8 +21,8 @@ class WritablePathValidator extends Zend_Validate_Abstract * @see Zend_Validate_Abstract::$_messageTemplates‚ */ protected $_messageTemplates = array( - 'NOT_WRITABLE' => 'Path is not writable', - 'DOES_NOT_EXIST' => 'Path does not exist' + self::NOT_WRITABLE => 'Path is not writable', + self::DOES_NOT_EXIST => 'Path does not exist' ); /** @@ -53,7 +56,7 @@ class WritablePathValidator extends Zend_Validate_Abstract $this->_setValue($value); if ($this->requireExistence && !file_exists($value)) { - $this->_error('DOES_NOT_EXIST'); + $this->_error(self::DOES_NOT_EXIST); return false; } @@ -62,7 +65,8 @@ class WritablePathValidator extends Zend_Validate_Abstract ) { return true; } - $this->_error('NOT_WRITABLE'); + + $this->_error(self::NOT_WRITABLE); return false; } }