mirror of
https://github.com/brmlab/brmsklad.git
synced 2025-08-03 22:53:58 +02:00
Upgrade CakePHP from 2.2.5 to 2.9.5
This commit is contained in:
parent
5a580df460
commit
235a541597
793 changed files with 60746 additions and 23753 deletions
|
@ -4,19 +4,18 @@
|
|||
*
|
||||
* Provides the Model validation logic.
|
||||
*
|
||||
* PHP versions 5
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @package Cake.Model.Validator
|
||||
* @since CakePHP(tm) v 2.2.0
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
App::uses('Validation', 'Utility');
|
||||
|
@ -40,7 +39,7 @@ class CakeValidationRule {
|
|||
/**
|
||||
* Holds whether the record being validated exists in datasource or not
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
protected $_recordExists = false;
|
||||
|
||||
|
@ -82,7 +81,7 @@ class CakeValidationRule {
|
|||
/**
|
||||
* The 'allowEmpty' key
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
public $allowEmpty = null;
|
||||
|
||||
|
@ -96,7 +95,7 @@ class CakeValidationRule {
|
|||
/**
|
||||
* The 'last' key
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
public $last = true;
|
||||
|
||||
|
@ -119,7 +118,7 @@ class CakeValidationRule {
|
|||
/**
|
||||
* Checks if the rule is valid
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function isValid() {
|
||||
if (!$this->_valid || (is_string($this->_valid) && !empty($this->_valid))) {
|
||||
|
@ -132,7 +131,7 @@ class CakeValidationRule {
|
|||
/**
|
||||
* Returns whether the field can be left blank according to this rule
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmptyAllowed() {
|
||||
return $this->skip() || $this->allowEmpty === true;
|
||||
|
@ -141,15 +140,14 @@ class CakeValidationRule {
|
|||
/**
|
||||
* Checks if the field is required according to the `required` property
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function isRequired() {
|
||||
if (in_array($this->required, array('create', 'update'), true)) {
|
||||
if ($this->required === 'create' && !$this->isUpdate() || $this->required === 'update' && $this->isUpdate()) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->required;
|
||||
|
@ -158,8 +156,9 @@ class CakeValidationRule {
|
|||
/**
|
||||
* Checks whether the field failed the `field should be present` validation
|
||||
*
|
||||
* @param array $data data to check rule against
|
||||
* @return boolean
|
||||
* @param string $field Field name
|
||||
* @param array &$data Data to check rule against
|
||||
* @return bool
|
||||
*/
|
||||
public function checkRequired($field, &$data) {
|
||||
return (
|
||||
|
@ -174,8 +173,9 @@ class CakeValidationRule {
|
|||
/**
|
||||
* Checks if the allowEmpty key applies
|
||||
*
|
||||
* @param array $data data to check rule against
|
||||
* @return boolean
|
||||
* @param string $field Field name
|
||||
* @param array &$data data to check rule against
|
||||
* @return bool
|
||||
*/
|
||||
public function checkEmpty($field, &$data) {
|
||||
if (empty($data[$field]) && $data[$field] != '0' && $this->allowEmpty === true) {
|
||||
|
@ -187,11 +187,11 @@ class CakeValidationRule {
|
|||
/**
|
||||
* Checks if the validation rule should be skipped
|
||||
*
|
||||
* @return boolean True if the ValidationRule can be skipped
|
||||
* @return bool True if the ValidationRule can be skipped
|
||||
*/
|
||||
public function skip() {
|
||||
if (!empty($this->on)) {
|
||||
if ($this->on == 'create' && $this->isUpdate() || $this->on == 'update' && !$this->isUpdate()) {
|
||||
if ($this->on === 'create' && $this->isUpdate() || $this->on === 'update' && !$this->isUpdate()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -199,10 +199,10 @@ class CakeValidationRule {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns whethere this rule should break validation process for associated field
|
||||
* Returns whether this rule should break validation process for associated field
|
||||
* after it fails
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function isLast() {
|
||||
return (bool)$this->last;
|
||||
|
@ -239,14 +239,15 @@ class CakeValidationRule {
|
|||
|
||||
/**
|
||||
* Sets the recordExists configuration value for this rule,
|
||||
* ir refers to wheter the model record it is validating exists
|
||||
* ir refers to whether the model record it is validating exists
|
||||
* exists in the collection or not (create or update operation)
|
||||
*
|
||||
* If called with no parameters it will return whether this rule
|
||||
* is configured for update operations or not.
|
||||
*
|
||||
* @return boolean
|
||||
**/
|
||||
* @param bool $exists Boolean to indicate if records exists
|
||||
* @return bool
|
||||
*/
|
||||
public function isUpdate($exists = null) {
|
||||
if ($exists === null) {
|
||||
return $this->_recordExists;
|
||||
|
@ -257,7 +258,10 @@ class CakeValidationRule {
|
|||
/**
|
||||
* Dispatches the validation rule to the given validator method
|
||||
*
|
||||
* @return boolean True if the rule could be dispatched, false otherwise
|
||||
* @param string $field Field name
|
||||
* @param array &$data Data array
|
||||
* @param array &$methods Methods list
|
||||
* @return bool True if the rule could be dispatched, false otherwise
|
||||
*/
|
||||
public function process($field, &$data, &$methods) {
|
||||
$this->_valid = true;
|
||||
|
@ -273,7 +277,7 @@ class CakeValidationRule {
|
|||
$this->_valid = call_user_func_array(array('Validation', $this->_rule), $this->_ruleParams);
|
||||
} elseif (is_string($validator['rule'])) {
|
||||
$this->_valid = preg_match($this->_rule, $data[$field]);
|
||||
} elseif (Configure::read('debug') > 0) {
|
||||
} else {
|
||||
trigger_error(__d('cake_dev', 'Could not find validation handler %s for %s', $this->_rule, $field), E_USER_WARNING);
|
||||
return false;
|
||||
}
|
||||
|
@ -282,11 +286,11 @@ class CakeValidationRule {
|
|||
}
|
||||
|
||||
/**
|
||||
* Resets interal state for this rule, by default it will become valid
|
||||
* Resets internal state for this rule, by default it will become valid
|
||||
* and it will set isUpdate() to false
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
*/
|
||||
public function reset() {
|
||||
$this->_valid = true;
|
||||
$this->_recordExists = false;
|
||||
|
@ -295,8 +299,9 @@ class CakeValidationRule {
|
|||
/**
|
||||
* Returns passed options for this rule
|
||||
*
|
||||
* @return array
|
||||
**/
|
||||
* @param string|int $key Array index
|
||||
* @return array|null
|
||||
*/
|
||||
public function getOptions($key) {
|
||||
if (!isset($this->_passedOptions[$key])) {
|
||||
return null;
|
||||
|
@ -328,6 +333,8 @@ class CakeValidationRule {
|
|||
/**
|
||||
* Parses the rule and sets the rule and ruleParams
|
||||
*
|
||||
* @param string $field Field name
|
||||
* @param array &$data Data array
|
||||
* @return void
|
||||
*/
|
||||
protected function _parseRule($field, &$data) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue