_messageTemplates = array( 'NOT_READABLE' => t('Path is not readable'), 'DOES_NOT_EXIST' => t('Path does not exist') ); } /** * Check whether the given value is a readable filepath * * @param string $value The value submitted in the form * @param mixed $context The context of the form * * @return bool Whether the value was successfully validated */ public function isValid($value, $context = null) { if (false === file_exists($value)) { $this->_error('DOES_NOT_EXIST'); return false; } if (false === is_readable($value)) { $this->_error('NOT_READABLE'); } return true; } }