コード例 #1
0
ファイル: RightTestCase.php プロジェクト: piece/piece-right
 function setUp()
 {
     Piece_Right_Error::pushCallback(create_function('$error', 'var_dump($error); return ' . PEAR_ERRORSTACK_DIE . ';'));
     $this->_cacheDirectory = dirname(__FILE__) . '/' . basename(__FILE__, '.php');
     $this->_oldFilterDirectories = $GLOBALS['PIECE_RIGHT_Filter_Directories'];
     Piece_Right_Filter_Factory::addFilterDirectory($this->_cacheDirectory);
     $this->_oldValidatorDirectories = $GLOBALS['PIECE_RIGHT_Validator_Directories'];
     Piece_Right_Validator_Factory::addValidatorDirectory($this->_cacheDirectory);
 }
コード例 #2
0
ファイル: ConfigTestCase.php プロジェクト: piece/piece-right
 function setUp()
 {
     Piece_Right_Error::pushCallback(create_function('$error', 'var_dump($error); return ' . PEAR_ERRORSTACK_DIE . ';'));
     $this->_config =& new Piece_Right_Config();
 }
コード例 #3
0
ファイル: Error.php プロジェクト: nyarla/fluxflex-rep2ex
 /**
  * Disables the last callback.
  *
  * @since Method available since Release 1.10.0
  */
 function disableCallback()
 {
     Piece_Right_Error::pushCallback(array(__CLASS__, 'handleError'));
 }
コード例 #4
0
ファイル: Right.php プロジェクト: piece/piece-right
 /**
  * Validates a field value by the given validations.
  *
  * @param string  $fieldName
  * @param string  $value
  * @param boolean $isFinals
  * @throws PIECE_RIGHT_ERROR_NOT_FOUND
  * @throws PIECE_RIGHT_ERROR_INVALID_VALIDATOR
  * @throws PIECE_RIGHT_ERROR_CANNOT_READ
  * @throws PIECE_RIGHT_ERROR_NOT_READABLE
  * @since Method available since Release 0.3.0
  */
 function _validateField($fieldName, $value, $isFinals)
 {
     foreach ($this->_config->getValidations($fieldName) as $validation) {
         if ($validation['useInFinals'] != $isFinals) {
             continue;
         }
         $validator =& Piece_Right_Validator_Factory::factory($validation['validator']);
         if (Piece_Right_Error::hasErrors('exception')) {
             return;
         }
         if (is_array($value) && !$validator->isArrayable()) {
             Piece_Right_Error::pushCallback(create_function('$error', 'return ' . PEAR_ERRORSTACK_PUSHANDLOG . ';'));
             Piece_Right_Error::push(PIECE_RIGHT_ERROR_NOT_ARRAYABLE, "The value of the field [ {$fieldName} ] is an array, but the validator [ {$validation['validator']} ] is not arrayable. This validation is skipped.", 'warning');
             Piece_Right_Error::popCallback();
             $this->_results->addError($fieldName, $validation['validator'], $validator->getMessage());
             continue;
         }
         $validator->setResults($this->_results);
         $validator->setRules($validation['rules']);
         $validator->setMessage($validation['message']);
         $validator->setPayload($this->_payload);
         if (!$validator->validate($value)) {
             $this->_results->addError($fieldName, $validation['validator'], $validator->getMessage());
         }
     }
 }