浏览代码

Fix up callbacks

dereuromark 8 年之前
父节点
当前提交
8ea253fa8e

+ 7 - 2
src/Model/Behavior/BitmaskedBehavior.php

@@ -78,9 +78,12 @@ class BitmaskedBehavior extends Behavior {
 	/**
 	 * @param \Cake\Event\Event $event
 	 * @param \Cake\ORM\Query $query
+	 * @param \ArrayObject $options
+	 * @param bool $primary
+	 *
 	 * @return void
 	 */
-	public function beforeFind(Event $event, Query $query) {
+	public function beforeFind(Event $event, Query $query, ArrayObject $options, $primary) {
 		$this->encodeBitmaskConditions($query);
 
 		$field = $this->_config['field'];
@@ -99,9 +102,11 @@ class BitmaskedBehavior extends Behavior {
 	 * @param \Cake\Event\Event $event
 	 * @param \Cake\Datasource\EntityInterface $entity
 	 * @param \ArrayObject $options
+	 * @param string $operation
+	 *
 	 * @return void
 	 */
-	public function beforeRules(Event $event, EntityInterface $entity, ArrayObject $options) {
+	public function beforeRules(Event $event, EntityInterface $entity, ArrayObject $options, $operation) {
 		if ($this->_config['on'] !== 'beforeRules' || !$options['checkRules']) {
 			return;
 		}

+ 4 - 1
src/Model/Behavior/JsonableBehavior.php

@@ -104,9 +104,12 @@ class JsonableBehavior extends Behavior {
 	 *
 	 * @param \Cake\Event\Event $event
 	 * @param \Cake\ORM\Query $query
+	 * @param \ArrayObject $options
+	 * @param bool $primary
+	 *
 	 * @return void
 	 */
-	public function beforeFind(Event $event, Query $query) {
+	public function beforeFind(Event $event, Query $query, ArrayObject $options, $primary) {
 		$query->formatResults(function ($results) {
 			return $results->map(function ($row) {
 				if (!$row instanceOf Entity) {

+ 1 - 1
src/Model/Behavior/PasswordableBehavior.php

@@ -325,7 +325,7 @@ class PasswordableBehavior extends Behavior {
 		if ($entity->get($formField) !== null) {
 			$cost = !empty($this->_config['hashCost']) ? $this->_config['hashCost'] : 10;
 			$options = ['cost' => $cost];
-			/** @var \Cake\Auth\AbstractPasswordHasher $PasswordHasher */
+			/* @var \Cake\Auth\AbstractPasswordHasher $PasswordHasher */
 			$PasswordHasher = $this->_getPasswordHasher($this->_config['passwordHasher'], $options);
 			$entity->set($field, $PasswordHasher->hash($entity->get($formField)));
 

+ 5 - 2
src/Model/Behavior/SluggedBehavior.php

@@ -163,9 +163,12 @@ class SluggedBehavior extends Behavior {
 	 *
 	 * @param \Cake\Event\Event $event
 	 * @param \Cake\Datasource\EntityInterface $entity
+	 * @param \ArrayObject $options
+	 * @param string $operation
+	 *
 	 * @return void
 	 */
-	public function beforeRules(Event $event, EntityInterface $entity) {
+	public function beforeRules(Event $event, EntityInterface $entity, ArrayObject $options, $operation) {
 		if ($this->_config['on'] === 'beforeRules') {
 			$this->slug($entity);
 		}
@@ -365,7 +368,7 @@ class SluggedBehavior extends Behavior {
 
 		$this->config($params, null, false);
 		while (($records = $this->_table->find('all', $params)->toArray())) {
-			/** @var \Cake\ORM\Entity $record */
+			/* @var \Cake\ORM\Entity $record */
 			foreach ($records as $record) {
 				$record->isNew(true);
 				$options = [

+ 4 - 1
src/Model/Behavior/StringBehavior.php

@@ -49,9 +49,12 @@ class StringBehavior extends Behavior {
 	 *
 	 * @param \Cake\Event\Event $event
 	 * @param \Cake\ORM\Query $query
+	 * @param \ArrayObject $options
+	 * @param bool $primary
+	 *
 	 * @return void
 	 */
-	public function beforeFind(Event $event, Query $query) {
+	public function beforeFind(Event $event, Query $query, ArrayObject $options, $primary) {
 		$query->formatResults(function (ResultSetInterface $results) {
 			return $results->map(function ($row) {
 				$this->processItems($row, 'output');

+ 2 - 5
tests/TestCase/Model/Behavior/PasswordableBehaviorTest.php

@@ -4,7 +4,7 @@ namespace Tools\Test\TestCase\Model\Behavior;
 
 use Cake\Auth\PasswordHasherFactory;
 use Cake\Core\Configure;
-use Cake\Network\Request;
+use Cake\Http\ServerRequest;
 use Cake\ORM\TableRegistry;
 use Cake\Routing\Router;
 use Tools\TestSuite\TestCase;
@@ -38,7 +38,7 @@ class PasswordableBehaviorTest extends TestCase {
 
 		$this->hasher = PasswordHasherFactory::build('Default');
 
-		Router::setRequestInfo(new Request());
+		Router::setRequestInfo(new ServerRequest());
 	}
 
 	/**
@@ -175,7 +175,6 @@ class PasswordableBehaviorTest extends TestCase {
 		$this->tearDown();
 		$this->setUp();
 
-		$this->Users->removeBehavior('Passwordable');
 		$this->Users->addBehavior('Tools.Passwordable', ['require' => false, 'current' => true]);
 		$user = $this->Users->newEntity();
 		$data = [
@@ -366,7 +365,6 @@ class PasswordableBehaviorTest extends TestCase {
 		$userCopy = clone($user);
 		$uid = $user->id;
 
-		$this->Users->removeBehavior('Passwordable');
 		$this->Users->addBehavior('Tools.Passwordable', ['current' => true]);
 		$user = clone($userCopy);
 		$data = [
@@ -452,7 +450,6 @@ class PasswordableBehaviorTest extends TestCase {
 		$userCopy = clone($user);
 		$uid = $user->id;
 
-		$this->Users->removeBehavior('Passwordable');
 		$this->Users->addBehavior('Tools.Passwordable', ['current' => true, 'require' => false]);
 		$user = clone($userCopy);
 		$data = [