# |
Feb 14th 2020, 16:51 |
ndm |
No problem |
# |
Feb 14th 2020, 16:50 |
lilhermit |
Thanks again for your time it's appreciated |
# |
Feb 14th 2020, 16:49 |
lilhermit |
I don't unfortunately I'll have a think on it |
# |
Feb 14th 2020, 16:46 |
ndm |
If you have any other unique identifier at hand, then you could probably workaround it with maybe some manual fiddling |
# |
Feb 14th 2020, 16:45 |
ndm |
You're welcome. |
# |
Feb 14th 2020, 16:45 |
lilhermit |
Thanks for your help |
# |
Feb 14th 2020, 16:44 |
lilhermit |
ok that makes it harder because that data comes from an API |
# |
Feb 14th 2020, 16:43 |
ndm |
correct |
# |
Feb 14th 2020, 16:43 |
lilhermit |
So I need the primary key in the $data array for the phone numbers? |
# |
Feb 14th 2020, 16:41 |
ndm |
There you go, the primary key is missing, the data only holds the phone number. I didn't specify it, but it needs to be present in the data that you want to patch the entities with, otherwise the marshaller has no idea into which entity the passed data needs to be merged. |
# |
Feb 14th 2020, 16:35 |
lilhermit |
https://pastebin.com/BhNy26TW |
# |
Feb 14th 2020, 16:30 |
lilhermit |
I have the data array and the user before and after patching |
# |
Feb 14th 2020, 16:30 |
lilhermit |
Yep just adding to pastebin |
# |
Feb 14th 2020, 16:30 |
ndm |
_before_ patching |
# |
Feb 14th 2020, 16:29 |
ndm |
I'll belive it when I see it ;) Can you show `debug()` of `$user` and `$data`? |
# |
Feb 14th 2020, 16:28 |
lilhermit |
The primary keys are there before the patch but after they are all new entities |
# |
Feb 14th 2020, 16:26 |
ndm |
What exactly is the final result in `phone_numbers`? I could imagine that it's missing the primary keys which are required for patching existing entities. |
# |
Feb 14th 2020, 16:26 |
lilhermit |
No data is changing but it always marks phone_numbers as dirty and duplicates them |
# |
Feb 14th 2020, 16:25 |
slackebot |
'{n}',function($number) { return ['number' => $number]; }) ];``` |
# |
Feb 14th 2020, 16:25 |
lilhermit |
The $data looks like ``` $data = [ 'uuid' => $graphUser->getId(), 'first_name' => $graphUser->getGivenName(), 'last_name' => $graphUser->getSurname(), 'email' => $graphUser->getMail(), 'job_title' => $graphUser->getJobTitle(), 'phone_numbers' => Hash::map($graphUser->getBusinessPhones(), |
# |
Feb 14th 2020, 16:24 |
lilhermit |
Patching like `$user = $this->Users->patchEntity($user, $data);` |
# |
Feb 14th 2020, 16:24 |
lilhermit |
sure, I load my entity like ``` $user = $this->Users->find('ByUuid', ['uuid' => $graphUser->getId()]) ->contain(['PhoneNumbers']) ->first();``` |
# |
Feb 14th 2020, 16:22 |
ndm |
@lilhermit I'm not sure, what does your data and code for patching/saving look like? |
# |
Feb 14th 2020, 16:20 |
ndm |
no problem |
# |
Feb 14th 2020, 16:20 |
sebastian.krzewinski. |
thanks |
# |
Feb 14th 2020, 16:20 |
sebastian.krzewinski. |
now is working :) |
# |
Feb 14th 2020, 16:19 |
sebastian.krzewinski. |
i see |
# |
Feb 14th 2020, 16:19 |
ndm |
@sebastian.krzewinski. Or wait, in CakePHP 4 it's `$this->disableAutoLayout();` now |
# |
Feb 14th 2020, 16:18 |
lilhermit |
@ndm Know anything about my saving with associations issue? |
# |
Feb 14th 2020, 16:17 |
sebastian.krzewinski. |
i will check |
# |
Feb 14th 2020, 16:17 |
ndm |
In that case you've probably removed the `$this->layout = false;` part in `home.php` file, which is responsible for disabling rendering in a layout. |
# |
Feb 14th 2020, 16:17 |
sebastian.krzewinski. |
https://i.imgur.com/pmCMN9h.png |
# |
Feb 14th 2020, 16:15 |
sebastian.krzewinski. |
pages/home.php is rendering inside layout/default.php |
# |
Feb 14th 2020, 16:14 |
sebastian.krzewinski. |
yes |
# |
Feb 14th 2020, 16:12 |
ndm |
By `default.php` do you mean a layout, ie `layout/default.php`? |
# |
Feb 14th 2020, 16:10 |
sebastian.krzewinski. |
in "/" |
# |
Feb 14th 2020, 16:10 |
sebastian.krzewinski. |
my home.php is looks like was rendering in default.php |
# |
Feb 14th 2020, 16:04 |
sebastian.krzewinski. |
i send you pm |
# |
Feb 14th 2020, 16:02 |
ndm |
@sebastian.krzewinski. You'll have to provide a little more details as to what exactly you've done, and what exactly the result is, "_2 pages in 1_" could mean all sorts of things. |
# |
Feb 14th 2020, 15:58 |
sebastian.krzewinski. |
im little bit confused bec. today i edit my home.php and its looks like 2 pages in 1 ( home and default) |
# |
Feb 14th 2020, 15:57 |
ndm |
@val Have you tried a custom (eager) loader as I've suggested? You can do all sorts of crazy things that way: https://gist.github.com/ndm2/b417e3fa683a972e295dc0e24ef515e3 |