# |
Dec 31st 2018, 16:09 |
NickBusey |
Not sure it's the docs at this point, I had it working, then it broke again, heh |
# |
Dec 31st 2018, 16:06 |
steinkel |
ok, if you need to wrestle, we didn't do it right (or we need to improve docs) possibly... |
# |
Dec 31st 2018, 16:05 |
NickBusey |
No problem, wrestling with it now still so I may have some more questions in a bit |
# |
Dec 31st 2018, 16:01 |
steinkel |
sorry I was not around to help when you were having issues with the api token integration, reading the chats now |
# |
Dec 31st 2018, 16:01 |
steinkel |
that's possibly a leftover in the docs as the auth plugin was integrated previously in users |
# |
Dec 31st 2018, 16:00 |
steinkel |
thank you, merged |
# |
Dec 31st 2018, 15:53 |
NickBusey |
Thanks challgren, also I had to change CakeDC/Users to CakeDC/Auth. Submitted a PR to fix the docs |
# |
Dec 31st 2018, 15:06 |
k4t |
thank you for your help, looks like everything iw roking now |
# |
Dec 31st 2018, 15:06 |
k4t |
it could be added to cookbook |
# |
Dec 31st 2018, 15:06 |
k4t |
yeah, I just noticed now that it is possible to use 3rd argument to overwtie where conditions |
# |
Dec 31st 2018, 15:01 |
admad |
@k4t that's cause you are not overwriting, read the API for where() |
# |
Dec 31st 2018, 14:46 |
k4t |
but it is just appending my new conditions so finally I have two Users.id conditions in final query |
# |
Dec 31st 2018, 14:45 |
slackebot |
<k4t> |
# |
Dec 31st 2018, 14:44 |
k4t |
@admad I did: |
# |
Dec 31st 2018, 14:21 |
admad |
@k4t yeah unfortunately those conditions are set after the custom finder is called. So you'll have to use crud's beforeFind event to reset the where() conditions as I showed earlier |
# |
Dec 31st 2018, 13:35 |
k4t |
I thinkthat it should not happen if I choose to pick my own finder |
# |
Dec 31st 2018, 13:34 |
k4t |
ad this is the reason of exception |
# |
Dec 31st 2018, 13:34 |
k4t |
‌array ( 'Users.id' => 'admin', ) |
# |
Dec 31st 2018, 13:33 |
k4t |
it is adding always additional where condition to the query even if custom finder is used |
# |
Dec 31st 2018, 13:33 |
k4t |
$query->where([current($query->aliasField($repository->getPrimaryKey())) => $id]); |
# |
Dec 31st 2018, 13:32 |
k4t |
by |
# |
Dec 31st 2018, 13:32 |
k4t |
ok, tis is caused by FindMethodTrait |
# |
Dec 31st 2018, 11:31 |
admad |
in your custom finder overwrite existing where() conditions |
# |
Dec 31st 2018, 11:29 |
admad |
follow the stack trace and find the relevant crud code |
# |
Dec 31st 2018, 11:28 |
k4t |
no, it is string |
# |
Dec 31st 2018, 11:27 |
challgren |
Is your ID integer? |
# |
Dec 31st 2018, 11:27 |
k4t |
I did not found yet why Integer is used |
# |
Dec 31st 2018, 11:27 |
k4t |
function |
# |
Dec 31st 2018, 11:27 |
k4t |
checkNumeric |
# |
Dec 31st 2018, 11:27 |
k4t |
\cakephp\cakephp\src\Database\Type\IntegerType.php |
# |
Dec 31st 2018, 11:26 |
admad |
check the stack trace and figure out what exactly triggers the exception |
# |
Dec 31st 2018, 11:25 |
k4t |
did not figure out solution yet |
# |
Dec 31st 2018, 11:25 |
k4t |
probably caused because now instead of id:integer i am passing string |
# |
Dec 31st 2018, 11:24 |
k4t |
but now I am getting exception: Cannot convert value of type `string` to integer |
# |
Dec 31st 2018, 11:23 |
admad |
yeah can also use custom find method |
# |
Dec 31st 2018, 11:23 |
slackebot |
<k4t> |
# |
Dec 31st 2018, 11:23 |
k4t |
with route: |
# |
Dec 31st 2018, 11:22 |
k4t |
this is what I tried |
# |
Dec 31st 2018, 11:22 |
slackebot |
<k4t> |
# |
Dec 31st 2018, 11:22 |
admad |
`view ($slug) { $this->Crud->on('beforeFind', function () {..}); $this->Crud->execute() }` |
# |
Dec 31st 2018, 11:21 |
admad |
you could also use plugin's ViewAction and use Crud.beforeFind() event to modify the query in your controller action |