File tree Expand file tree Collapse file tree 2 files changed +4
-9
lines changed Expand file tree Collapse file tree 2 files changed +4
-9
lines changed Original file line number Diff line number Diff line change @@ -55,15 +55,15 @@ class JsonAttributeBehavior extends AttributeBehavior
55
55
public function events (): array
56
56
{
57
57
return [
58
- Model::EVENT_BEFORE_VALIDATE => 'beforeValidate ' ,
59
- Model::EVENT_AFTER_VALIDATE => 'afterValidate '
58
+ Model::EVENT_BEFORE_VALIDATE => 'ensureValueIsArray ' ,
59
+ Model::EVENT_AFTER_VALIDATE => 'convertBackToOriginalTypeIfNeeded '
60
60
];
61
61
}
62
62
63
63
/**
64
64
* Ensure that the attribute value is an array if it is a string.
65
65
*/
66
- public function beforeValidate (): void
66
+ public function ensureValueIsArray (): void
67
67
{
68
68
foreach ($ this ->attributes as $ attribute ) {
69
69
if (is_string ($ this ->owner ->$ attribute )) {
@@ -83,7 +83,7 @@ public function beforeValidate(): void
83
83
/**
84
84
* Ensure that the attribute will be converted back to its original type if an error occurs.
85
85
*/
86
- public function afterValidate (): void
86
+ public function convertBackToOriginalTypeIfNeeded (): void
87
87
{
88
88
if ($ this ->owner ->hasErrors () || $ this ->alwaysConvertBackToOriginalType ) {
89
89
foreach ($ this ->attributes as $ attribute ) {
Original file line number Diff line number Diff line change 1
1
<?xml version =" 1.0" encoding =" UTF-8" ?>
2
2
<phpunit xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" bootstrap =" bootstrap.php" xsi : noNamespaceSchemaLocation =" https://schema.phpunit.de/10.5/phpunit.xsd" >
3
- <source >
4
- <include >
5
- <directory >../src/</directory >
6
- </include >
7
- </source >
8
3
</phpunit >
You can’t perform that action at this time.
0 commit comments