Why new entities created with a zero value for all values, except for the data in json, why the constructor of the object does not set default values ββ- setting die () in the constructor is never performed.
Update:
So, transcode the code when the managed object is not found, JMSS will use the doctinary doctrine class to create the object - its only task is to create objects without calling the constructor. Is there a reason for this? this is inside JMS\Serializer\Construction\UnserializeObjectConstructor
I configured the object constructor to use the doctrine object constructor written by JMS, but the same problem occurs without it.
jms_serializer.object_constructor: alias: jms_serializer.doctrine_object_constructor public: false
Existing objects are updated without problems, but new entities lack all the default values ββfor the constructor.
In the element "fields" 0 there is an element 1, new.
array (size=3) 'id' => int 2 'name' => string 'Categories' (length=10) 'fields' => array (size=2) 0 => array (size=7) 'id' => int 49 'displayName' => string 'Car Branded' (length=11) 'type' => string 'checkboxlist' (length=12) 'required' => boolean false 'disabled' => boolean false 'name' => string 'h49' (length=3) 1 => array (size=3) 'type' => string 'email' (length=5) 'name' => string 'field3491' (length=9) 'displayName' => string 'Email' (length=5)
The entity is as follows after deserialization:
object(stdClass)[2000] public '__CLASS__' => string 'AppBundle\Entity\FormElement' (length=28) public 'id' => null public 'label' => string 'Email' (length=5) public 'type' => string 'email' (length=5) public 'defaultValue' => null public 'required' => null public 'mappedField' => null public 'garbageCollection' => null public 'sortOrder' => null public 'disabled' => null public 'uuid' => null public 'form' => null public 'multiOptions' => null public 'filters' => null public 'submissions' => null
Object constructor:
public function __construct() { $this->required = false; $this->disabled = false; $this->garbageCollection = false; $this->sortOrder = 0; $this->type = 'text'; }
And finally, this is how im deserializing:
$serializer = $this->get('jms_serializer'); $entryForm = $serializer->deserialize($json_data, 'AppBundle\Entity\EntryForm', 'json');