# |
Jan 5th 2020, 14:27 |
racmiroslav |
maybe by setting the accept header for every request somewhere in middleware? |
# |
Jan 5th 2020, 14:26 |
racmiroslav |
I have some specific requirement. Is there a way to force cake to handle my request as if extension or header was set to json? But I do not want client to have a control over it. |
# |
Jan 5th 2020, 14:24 |
challgren |
Its best not to force rendering, use the extensions and http headers |
# |
Jan 5th 2020, 14:23 |
racmiroslav |
@challgren thank you! |
# |
Jan 5th 2020, 14:23 |
challgren |
https://book.cakephp.org/3/en/development/routing.html#Cake\Routing\Router::extensions |
# |
Jan 5th 2020, 14:21 |
challgren |
add extension .json or when requesting add Accept: application/json |
# |
Jan 5th 2020, 14:19 |
racmiroslav |
Hello guys. I use ```$this->RequestHandler->renderAs($this, 'json');``` to force json responses. It works just fine, however, errors are rendered as HTML, eg. for ```throw new NotFoundException();``` I expect to get some json with “error” properties. I do get regular HTML error. (error400.ctp) |
# |
Jan 5th 2020, 11:56 |
admad |
geoffo: submit a issue on the cakephp/upgrade repo |
# |
Jan 5th 2020, 01:00 |
geoffo |
anybody run into this exception when trying to use the 4.0 upgrader (from 3.8)? `fatal: source directory is empty, source=templates/Layout/Email, destination=templates/Layout/email_` ? |
# |
Jan 4th 2020, 23:32 |
luizcmarin |
I did not rename the table. But it excludes everything bake generated for forma_pgtos and people, and then I generated it again. It worked like that. thanks for the tip |
# |
Jan 4th 2020, 22:41 |
d.lisiecki93 |
@luizcmarin from what i know cake durring bake checks schema and table classes generally and will throw an error if there's something wrong, from what i see you have naming conflict - in database you have table called "forma_pgtos" and somewhere in table class u declared table name as "formapgtos" |
# |
Jan 4th 2020, 22:31 |
luizcmarin |
I tried with other tables. The same thing ! Locked in this thankless table. Buffer? cache? I will restart the machine |
# |
Jan 4th 2020, 22:27 |
luizcmarin |
I have a table called 'forma_pgtos', but not linked to 'people' . I'm trying to understand what connection cake makes |
# |
Jan 4th 2020, 22:26 |
slackebot |
<luizcmarin> |
# |
Jan 4th 2020, 22:25 |
luizcmarin |
Hi. I have a strange doubt. I tried to use bake to create all screens in the 'people' table, but it raises errors in another table with no link between them. |
# |
Jan 4th 2020, 21:11 |
d.lisiecki93 |
huh funny fact mate, in my country "JP" which pronounces exactly by "jotpe" means literally "fuck the police" (Jebać Policje) |
# |
Jan 4th 2020, 21:10 |
slackebot |
{$this->currency->system_code})"; }``` but obviously `translation` method does not exists on `PaymentType` object, i think i can achieve this by running `i18n::setLocale` to origin and then back to the, lets say, "session locale", but i feel like this is really bad approach, any ideas fellas? |
# |
Jan 4th 2020, 21:10 |
d.lisiecki93 |
gi guys, it's again me with another boring problem - i'm using i18n translations, everything works fine, but i need one non-standard thing - i would like to have virtual getter which would return mixed value of other fields BUT in my default i18n locale, so basically something like: ``` protected function _getNameWithPriceOrigin() { return "{$this->payment_type->translation('pl')->name} ({$this->amount} |
# |
Jan 4th 2020, 16:05 |
jotpe |
Hi! |
# |
Jan 4th 2020, 12:53 |
etibor |
hello mates |
# |
Jan 4th 2020, 10:33 |
ndm |
If you want to restrict access to an action/endpoint altogether, then you may want to look into the request authorization middleware. https://book.cakephp.org/authorization/2/en/request-authorization-middleware.html |
# |
Jan 4th 2020, 10:11 |
mrfeedback |
whats the best approach to use authoriazation plugin on index actions in a controller? I know that I should use the applyScope function but for me it doesn´t feel like it is the right solution therefore as I want to check if the user is allowed to access this section and not only alter the query on user level |
# |
Jan 3rd 2020, 21:50 |
ricksaccous |
yep |
# |
Jan 3rd 2020, 21:50 |
d.lisiecki93 |
again thanks mate |
# |
Jan 3rd 2020, 21:50 |
d.lisiecki93 |
yeah, i just wasted 1,5 hour of struggling with that and trying to figure out if it's my bad or plugin bug, but ye, no curse needed there |
# |
Jan 3rd 2020, 21:49 |
ricksaccous |
no need to curse lad, but no problem |
# |
Jan 3rd 2020, 21:49 |
d.lisiecki93 |
xD |
# |
Jan 3rd 2020, 21:49 |
ricksaccous |
XD |
# |
Jan 3rd 2020, 21:49 |
d.lisiecki93 |
fuck me, you're right, i'm dumb, i didn't noticed this difference at all, was focused on data types all the time, thank you so much |
# |
Jan 3rd 2020, 21:47 |
ricksaccous |
you have serialize set to be an array |
# |
Jan 3rd 2020, 21:47 |
ricksaccous |
they just set $_serialize to a string called 'data' |
# |
Jan 3rd 2020, 21:46 |
ricksaccous |
you have some differences |
# |
Jan 3rd 2020, 21:46 |
ricksaccous |
nah not really |
# |
Jan 3rd 2020, 21:46 |
d.lisiecki93 |
as on screen above, which is doc from it |
# |
Jan 3rd 2020, 21:46 |
slackebot |
<ricksaccous> |
# |
Jan 3rd 2020, 21:46 |
d.lisiecki93 |
@ricksaccous my data structure is basically the same |
# |
Jan 3rd 2020, 21:46 |
slackebot |
<d.lisiecki93> |
# |
Jan 3rd 2020, 21:46 |
ricksaccous |
also just follow the example code more closely... |
# |
Jan 3rd 2020, 21:45 |
ricksaccous |
a header is just a row |
# |
Jan 3rd 2020, 21:44 |
ricksaccous |
... |
# |
Jan 3rd 2020, 21:44 |
ricksaccous |
why would you want a multi-dimensional array header? |