I have a MongoDB Document called User. I also have the array containing all possible "updatable" fields (this is for an API where a third party can update fields in my DB by sending a request). I want to do something like:
$user_document->set(array($field => $value));
$document_manager->flush();
Where $user_document is the document got by FindOneBy, and $field and $value are the values from the API request. This does not work. How to manually insert value to a given field? I dont want to use setFieldName method, because there are a lot of fields and I want to keep them in an array.