Upgrade CakePHP from 2.2.5 to 2.9.5

This commit is contained in:
Brm Ko 2017-02-26 15:29:44 +01:00
parent 5a580df460
commit 235a541597
793 changed files with 60746 additions and 23753 deletions

View file

@ -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('CakeValidationRule', 'Model/Validator');
@ -33,7 +32,7 @@ class CakeValidationSet implements ArrayAccess, IteratorAggregate, Countable {
/**
* Holds the CakeValidationRule objects
*
* @var array
* @var CakeValidationRule[]
*/
protected $_rules = array();
@ -41,20 +40,20 @@ class CakeValidationSet implements ArrayAccess, IteratorAggregate, Countable {
* List of methods available for validation
*
* @var array
**/
*/
protected $_methods = array();
/**
* I18n domain for validation messages.
*
* @var string
**/
*/
protected $_validationDomain = null;
/**
* Whether the validation is stopped
*
* @var boolean
* @var bool
*/
public $isStopped = false;
@ -75,8 +74,8 @@ class CakeValidationSet implements ArrayAccess, IteratorAggregate, Countable {
/**
* Constructor
*
* @param string $fieldName The fieldname
* @param array $ruleset
* @param string $fieldName The fieldname.
* @param array $ruleSet Rules set.
*/
public function __construct($fieldName, $ruleSet) {
$this->field = $fieldName;
@ -94,8 +93,9 @@ class CakeValidationSet implements ArrayAccess, IteratorAggregate, Countable {
/**
* Sets the list of methods to use for validation
*
* @param array &$methods Methods list
* @return void
**/
*/
public function setMethods(&$methods) {
$this->_methods =& $methods;
}
@ -114,6 +114,8 @@ class CakeValidationSet implements ArrayAccess, IteratorAggregate, Countable {
* Runs all validation rules in this set and returns a list of
* validation errors
*
* @param array $data Data array
* @param bool $isUpdate Is record being updated or created
* @return array list of validation errors for this field
*/
public function validate($data, $isUpdate = false) {
@ -145,10 +147,10 @@ class CakeValidationSet implements ArrayAccess, IteratorAggregate, Countable {
}
/**
* Resets interal state for all validation rules in this set
* Resets internal state for all validation rules in this set
*
* @return void
**/
*/
public function reset() {
foreach ($this->getRules() as $rule) {
$rule->reset();
@ -158,7 +160,7 @@ class CakeValidationSet implements ArrayAccess, IteratorAggregate, Countable {
/**
* Gets a rule for a given name if exists
*
* @param string $name
* @param string $name Field name.
* @return CakeValidationRule
*/
public function getRule($name) {
@ -170,7 +172,7 @@ class CakeValidationSet implements ArrayAccess, IteratorAggregate, Countable {
/**
* Returns all rules for this validation set
*
* @return array
* @return CakeValidationRule[]
*/
public function getRules() {
return $this->_rules;
@ -181,15 +183,15 @@ class CakeValidationSet implements ArrayAccess, IteratorAggregate, Countable {
*
* ## Example:
*
* {{{
* ```
* $set
* ->setRule('required', array('rule' => 'notEmpty', 'required' => true))
* ->setRule('inRange', array('rule' => array('between', 4, 10))
* }}}
* ->setRule('required', array('rule' => 'notBlank', 'required' => true))
* ->setRule('between', array('rule' => array('lengthBetween', 4, 10))
* ```
*
* @param string $name The name under which the rule should be set
* @param CakeValidationRule|array $rule The validation rule to be set
* @return CakeValidationSet this instance
* @return self
*/
public function setRule($name, $rule) {
if (!($rule instanceof CakeValidationRule)) {
@ -204,14 +206,14 @@ class CakeValidationSet implements ArrayAccess, IteratorAggregate, Countable {
*
* ## Example:
*
* {{{
* ```
* $set
* ->removeRule('required')
* ->removeRule('inRange')
* }}}
* ```
*
* @param string $name The name under which the rule should be unset
* @return CakeValidationSet this instance
* @return self
*/
public function removeRule($name) {
unset($this->_rules[$name]);
@ -223,16 +225,16 @@ class CakeValidationSet implements ArrayAccess, IteratorAggregate, Countable {
*
* ## Example:
*
* {{{
* ```
* $set->setRules(array(
* 'required' => array('rule' => 'notEmpty', 'required' => true),
* 'required' => array('rule' => 'notBlank', 'required' => true),
* 'inRange' => array('rule' => array('between', 4, 10)
* ));
* }}}
* ```
*
* @param array $rules The rules to be set
* @param bolean $mergeVars [optional] If true, merges vars instead of replace. Defaults to true.
* @return ModelField
* @param bool $mergeVars [optional] If true, merges vars instead of replace. Defaults to true.
* @return self
*/
public function setRules($rules = array(), $mergeVars = true) {
if ($mergeVars === false) {
@ -303,11 +305,11 @@ class CakeValidationSet implements ArrayAccess, IteratorAggregate, Countable {
}
/**
* Returns wheter an index exists in the rule set
* Returns whether an index exists in the rule set
*
* @param string $index name of the rule
* @return boolean
**/
* @return bool
*/
public function offsetExists($index) {
return isset($this->_rules[$index]);
}
@ -317,17 +319,22 @@ class CakeValidationSet implements ArrayAccess, IteratorAggregate, Countable {
*
* @param string $index name of the rule
* @return CakeValidationRule
**/
*/
public function offsetGet($index) {
return $this->_rules[$index];
}
/**
* Sets or replace a validation rule
* Sets or replace a validation rule.
*
* @param string $index name of the rule
* @param CakeValidationRule|array rule to add to $index
**/
* This is a wrapper for ArrayAccess. Use setRule() directly for
* chainable access.
*
* @param string $index Name of the rule.
* @param CakeValidationRule|array $rule Rule to add to $index.
* @return void
* @see http://www.php.net/manual/en/arrayobject.offsetset.php
*/
public function offsetSet($index, $rule) {
$this->setRule($index, $rule);
}
@ -337,7 +344,7 @@ class CakeValidationSet implements ArrayAccess, IteratorAggregate, Countable {
*
* @param string $index name of the rule
* @return void
**/
*/
public function offsetUnset($index) {
unset($this->_rules[$index]);
}
@ -346,7 +353,7 @@ class CakeValidationSet implements ArrayAccess, IteratorAggregate, Countable {
* Returns an iterator for each of the rules to be applied
*
* @return ArrayIterator
**/
*/
public function getIterator() {
return new ArrayIterator($this->_rules);
}
@ -355,7 +362,7 @@ class CakeValidationSet implements ArrayAccess, IteratorAggregate, Countable {
* Returns the number of rules in this set
*
* @return int
**/
*/
public function count() {
return count($this->_rules);
}