# |
Sep 16th 2019, 19:27 |
slackebot |
<jotpe> |
# |
Sep 16th 2019, 19:27 |
jotpe |
I've got a setter in my Entity for a field: |
# |
Sep 16th 2019, 18:36 |
ricksaccous |
@maymeow i've never tried to do that but i found this https://github.com/naneau/php-obfuscator |
# |
Sep 16th 2019, 18:30 |
maymeow |
i need advise. I have php application but i want protect some code from altering by users. Can be done something like this in php? (its problem because php apps is distributed as plain text not in compiled form) |
# |
Sep 16th 2019, 18:08 |
henri.mjr |
I understand.. worked now, thanks |
# |
Sep 16th 2019, 18:05 |
ricksaccous |
you can never do it the way you are attempting regardless since request data is immutable |
# |
Sep 16th 2019, 17:59 |
henri.mjr |
argh.. token was not accessible! |
# |
Sep 16th 2019, 17:56 |
henri.mjr |
uhmm |
# |
Sep 16th 2019, 17:56 |
ricksaccous |
yes, $this->request/$this->getRequest() are immutable |
# |
Sep 16th 2019, 17:55 |
admad |
@henri.mjr `$data = $this->request->getData()' unset($data['token'], $data['time_out']); $user = $this->Usuarios->patchEntity($user, $data);` |
# |
Sep 16th 2019, 17:43 |
henri.mjr |
$user['token'] is filled :( |
# |
Sep 16th 2019, 17:42 |
henri.mjr |
Hello! How it's the correct way to unset a field before patch? `$this->request->data['token'] = null;` ` $this->request->data['token_timeout'] = null;` ` $user = $this->Usuarios->patchEntity($user, $this->request->getData());` |
# |
Sep 16th 2019, 17:36 |
jotpe |
Thanks for your help, @javier.villanueva |
# |
Sep 16th 2019, 17:36 |
jotpe |
$confirmationsTable = TableRegistry::getTableLocator()->get('Users.EmailaddressConfirmations'); |
# |
Sep 16th 2019, 17:36 |
jotpe |
it's always the same. I run into the trap of not specifiying the plugin when getting the table... |
# |
Sep 16th 2019, 17:35 |
jotpe |
DAMN. |
# |
Sep 16th 2019, 17:20 |
javier.villanueva |
yes... if you dont want save two times, you can use a database trigger |
# |
Sep 16th 2019, 17:20 |
jotpe |
Wait |
# |
Sep 16th 2019, 17:20 |
jotpe |
So i have to set before |
# |
Sep 16th 2019, 17:20 |
jotpe |
I guess that should break the foreign key constraint |
# |
Sep 16th 2019, 17:20 |
javier.villanueva |
fuck return |
# |
Sep 16th 2019, 17:19 |
javier.villanueva |
if ($confirmationTable->save($confirmation)) { $confirmation->emailaddress_id = $confirmation->id; } |
# |
Sep 16th 2019, 17:18 |
javier.villanueva |
I dont know if is possible |
# |
Sep 16th 2019, 17:17 |
javier.villanueva |
with a field or the same entity |
# |
Sep 16th 2019, 17:17 |
javier.villanueva |
do you want to set this field always (auto) |
# |
Sep 16th 2019, 17:17 |
javier.villanueva |
ok I understand now |
# |
Sep 16th 2019, 17:16 |
jotpe |
'emailaddress_id' => $entity->id |
# |
Sep 16th 2019, 17:16 |
jotpe |
I set the entity_id when creating the newEntity |
# |
Sep 16th 2019, 17:15 |
javier.villanueva |
it creates the protection entity with emailaddress_id to "null"? |
# |
Sep 16th 2019, 17:15 |
jotpe |
yes |
# |
Sep 16th 2019, 17:15 |
slackebot |
<jotpe> |
# |
Sep 16th 2019, 17:15 |
javier.villanueva |
the new confirmation? |
# |
Sep 16th 2019, 17:14 |
javier.villanueva |
and the entity is created? |
# |
Sep 16th 2019, 17:14 |
jotpe |
I have |
# |
Sep 16th 2019, 17:14 |
javier.villanueva |
because this is the solution |
# |
Sep 16th 2019, 17:13 |
jotpe |
yes |
# |
Sep 16th 2019, 17:13 |
javier.villanueva |
check if you has access to this field in Entity |
# |
Sep 16th 2019, 17:07 |
jotpe |
Unfortunately setting the field in the constructor didn't worked |
# |
Sep 16th 2019, 17:06 |
slackebot |
<jotpe> |
# |
Sep 16th 2019, 17:05 |
jotpe |
When I create a new Entity with NewEntity() I want to automatically set a field in the entity. How can I do that? |
# |
Sep 16th 2019, 16:37 |
daniel.upshaw |
Found this too @felipe.marinho https://github.com/WyriHaximus/cakephp-async-orm |