Browse Source

Fix RC1 broken things.

euromark 11 years ago
parent
commit
70c5a40e4f

+ 3 - 3
src/Model/Behavior/ResetBehavior.php

@@ -8,7 +8,7 @@ use Cake\ORM\Table;
 
 /**
  * Allows the model to reset all records as batch command.
- * This way any slugging, geocoding or other beforeValidate, beforeSave, ... callbacks
+ * This way any slugging, geocoding or other beforeRules, beforeSave, ... callbacks
  * can be retriggered for them.
  *
  * By default it will not update the modified timestamp and will re-save id and displayName.
@@ -49,7 +49,7 @@ class ResetBehavior extends Behavior {
 		'timeout' => null, // in seconds
 		'fields' => array(), // if not displayField
 		'updateFields' => array(), // if saved fields should be different from fields
-		'validate' => true, // trigger beforeValidate callback
+		'validate' => true, // trigger beforeRules callback
 		'updateTimestamp' => false, // update modified/updated timestamp
 		'scope' => array(), // optional conditions
 		'callback' => null,
@@ -71,7 +71,7 @@ class ResetBehavior extends Behavior {
 	}
 
 	/**
-	 * Regenerate all records (including possible beforeValidate/beforeSave callbacks).
+	 * Regenerate all records (including possible beforeRules/beforeSave callbacks).
 	 *
 	 * @param Model $Model
 	 * @param array $conditions

+ 6 - 6
src/Model/Behavior/SluggedBehavior.php

@@ -52,7 +52,7 @@ class SluggedBehavior extends Behavior {
 	 * 	title - force title case. E.g. "This-Is-The-Slug"
 	 * 	camel - force CamelCase. E.g. "ThisIsTheSlug"
 	 * - replace: custom replacements as array
-	 * - on: beforeSave or beforeValidate
+	 * - on: beforeSave or beforeRules
 	 * - scope: certain conditions to use as scope
 	 * - tidy: If cleanup should be run on slugging
 	 *
@@ -74,7 +74,7 @@ class SluggedBehavior extends Behavior {
 			'+' => 'and',
 			'#' => 'hash',
 		),
-		'on' => 'beforeValidate',
+		'on' => 'beforeRules',
 		'scope' => array(),
 		'tidy' => true,
 		'implementedFinders' => ['slugged' => 'findSlugged'],
@@ -152,14 +152,14 @@ class SluggedBehavior extends Behavior {
 	}
 
 	/**
-	 * SluggedBehavior::beforeValidate()
+	 * SluggedBehavior::beforeRules()
 	 *
 	 * @param mixed $event
 	 * @param mixed $entity
 	 * @return void
 	 */
-	public function beforeValidate(Event $event, Entity $entity) {
-		if ($this->_config['on'] === 'beforeValidate') {
+	public function beforeRules(Event $event, Entity $entity) {
+		if ($this->_config['on'] === 'beforeRules') {
 			$this->slug($entity);
 		}
 	}
@@ -462,7 +462,7 @@ class SluggedBehavior extends Behavior {
 					$res = $this->generateSlug($field[$locale], $entity);
 				}
 			}
-			//$this->beforeValidate($entity);
+			//$this->beforeRules($entity);
 			$locale[$locale] = $res;
 		}
 		$entity->set($slugField, $locale);

+ 1 - 0
tests/TestCase/Model/Behavior/SluggedBehaviorTest.php

@@ -590,6 +590,7 @@ class SluggedBehaviorTest extends TestCase {
  * @return Entity
  */
 	protected function _getEntity($title = 'test 123', $field = 'title', array $options = array()) {
+		$options += ['validate' => false];
 		return new Entity([
 			$field => $title
 		], $options);