Skip to content

Commit 704e3ae

Browse files
committed
Fix update rawModelDataInput on setter call
1 parent f6da899 commit 704e3ae

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

docs/source/gettingStarted.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ Immutable classes
147147
148148
setImmutable(bool $immutable);
149149
150-
If set to true the generated model classes will be delivered without setter methods for the object properties. By default the classes are generated without setter methods.
150+
If set to true the generated model classes will be delivered without setter methods for the object properties. By default the classes are generated without setter methods. Each setter will validate the provided value and throw either a specific exception or a collection exception depending on the `error collection configuration <#collect-errors-vs-early-return>`__. If all validations pass the internal value will be updated as well as the value which will be returned when `getRawModelDataInput` is called.
151151

152152
.. code-block:: php
153153

src/Templates/Model.phptpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ class {{ class }} {% if schema.getInterfaces() %}implements {{ viewHelper.joinCl
136136
{% endif %}
137137

138138
$this->{{ property.getAttribute() }} = $value;
139+
$this->rawModelDataInput['{{ property.getName() }}'] = ${{ property.getAttribute() }};
139140

140141
{{ schemaHookResolver.resolveSetterAfterValidationHook(property) }}
141142

tests/Basic/FilterTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,14 @@ public function testCustomFilter(?string $input, ?string $expectedValue): void
268268

269269
$object = new $className(['property' => $input]);
270270
$this->assertSame($expectedValue, $object->getProperty());
271+
$this->assertSame($input, $object->getRawModelDataInput()['property']);
271272

272273
$object->setProperty($input);
273274
$this->assertSame($expectedValue, $object->getProperty());
275+
276+
$object->setProperty('hi');
277+
$this->assertSame('HI', $object->getProperty());
278+
$this->assertSame('hi', $object->getRawModelDataInput()['property']);
274279
}
275280

276281
public function customFilterDataProvider(): array

0 commit comments

Comments
 (0)