Skip to content

Commit 96af950

Browse files
committed
deprecate Form::_execute
1 parent af468b0 commit 96af950

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/Form/Form.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use Cake\Utility\Hash;
2424
use Cake\Validation\ValidatorAwareInterface;
2525
use Cake\Validation\ValidatorAwareTrait;
26+
use function Cake\Core\deprecationWarning;
2627

2728
/**
2829
* Form abstraction used to create forms not tied to ORM backed models,
@@ -282,6 +283,21 @@ public function execute(array $data, array $options = []): bool
282283
* @return bool
283284
*/
284285
protected function _execute(array $data): bool
286+
{
287+
deprecationWarning('5.3.0', 'The _execute() method is deprecated. Override the process() method instead.');
288+
289+
return $this->process($data);
290+
}
291+
292+
/**
293+
* Hook method to be implemented in subclasses.
294+
*
295+
* Used by `execute()` to execute the form's action.
296+
*
297+
* @param array $data Form data.
298+
* @return bool
299+
*/
300+
protected function process(array $data): bool
285301
{
286302
return true;
287303
}

tests/TestCase/Form/FormTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,9 @@ public function testExecuteValid(): void
193193
'email' => 'test@example.com',
194194
];
195195

196-
$this->assertTrue($form->execute($data));
196+
$this->deprecated(function () use ($form, $data): void {
197+
$this->assertTrue($form->execute($data));
198+
});
197199
}
198200

199201
/**
@@ -208,7 +210,9 @@ public function testExecuteSkipValidation(): void
208210
'email' => 'wrong',
209211
];
210212

211-
$this->assertTrue($form->execute($data, ['validate' => false]));
213+
$this->deprecated(function () use ($form, $data): void {
214+
$this->assertTrue($form->execute($data, ['validate' => false]));
215+
});
212216
}
213217

214218
/**

0 commit comments

Comments
 (0)