# |
Jun 29th 2021, 19:42 |
tyler.adam.lazenby |
Hey @dereuromark Does your queue plugin default email task support sending HTML emails? |
# |
Jun 29th 2021, 19:18 |
slackebot |
https://stackoverflow.com/questions/68184422/restrict-query-results-on-beforefind-table-call-back-without-breaking-buildrul |
# |
Jun 29th 2021, 19:18 |
jadelbe418 |
I am running into some issues with sorting logic on a beforeFind() getting applied to constraints in the buildRules() when it should not be, on some legacy Cake 3 code I maintain. I was wondering if there is a better approach to implementing this than what I have in place. I wrote my question out with code samples on SO: |
# |
Jun 29th 2021, 16:42 |
umer936 |
Yes, i get it while developing on Windows with PHPStorm. Never figured how to fix so I just run phpcs manually instead |
# |
Jun 29th 2021, 16:04 |
japerlman |
@kevin.pfeifer Thanks for the feedback, I appreciate it. |
# |
Jun 29th 2021, 15:31 |
ndm |
You gotta be careful with the term "request", that could easily be interpreted as "HTTP request", but I guess you're most likely referring to invoking some kind of read operation on a query/result in one and the same HTTP request? An answer to your question probably depends on how you generate the result set, how/where you apply the mapping, if you possibly reassign results, etc... so a code example might help here. |
# |
Jun 29th 2021, 15:25 |
kevin.pfeifer |
@japerlman I would say either way is totally OK, it just depends what you/your customer prefers as a frontend experience and what you as a developer are more used to. |
# |
Jun 29th 2021, 15:23 |
dereuromark |
Well, it is possible the the intoduced warning is a bit too harsh for some use cases, sure |
# |
Jun 29th 2021, 15:22 |
slackebot |
react just because 'it is the modern way'. am I wasting my time and is there anything 'wrong' with just doing it 100% in cakephp like I've done previously? |
# |
Jun 29th 2021, 15:22 |
japerlman |
I have very limited experience in web app dev and want to make sure I'm not approaching things incorrectly. If you were making an app that is just mostly data in/data out forms and reports is there any benefit to doing the backend in cakephp and exposing the api to a react front end? I've done two apps in the past 100% in cakephp 2 and 3 and I'm struggling with all the extra work to do the backend in cakephp and the frontend in |
# |
Jun 29th 2021, 15:11 |
ndm |
Of course, I just don't see why it would be a problem in this specific case, unless the association is actually using a different target. Maybe I've overlooked that, and that is actually the case. |
# |
Jun 29th 2021, 15:07 |
dereuromark |
npm: Sure, if those were fullly identical. but you could configure them slightly different each time, and in that case it would silently use a different one than you might want. So I guess that might have been the reason for the warning and the core to be a bit more strict since 4.1+ |
# |
Jun 29th 2021, 15:05 |
ndm |
@conehead Did you check if using `getTarget()` makes a difference, like `$this->Users->Books->getTarget()->find()->...`? |
# |
Jun 29th 2021, 15:03 |
ndm |
Didn't follow the whole saga... but that looks a bit weird, why would using the same alias be a problem here when the parent is a different object? Shouldn't that work fine if the target/classname are the same? :thinking_face: |
# |
Jun 29th 2021, 14:35 |
dereuromark |
what we wish and reality often dont go hand in hand. While I agree with u, it is not feasible here, unfortunately |
# |
Jun 29th 2021, 14:34 |
conehead |
Not convenient to have: Users->contain(['UsersTags']); Employees->contain(['EmployeesTags']); I'd prefer to have: Users->contain(['Tags']); Employees->contain(['Tags']); and use some internal alias |
# |
Jun 29th 2021, 14:33 |
dereuromark |
thus the unique names here (aliases). |
# |
Jun 29th 2021, 14:33 |
dereuromark |
well, relations (assoc) have to be unique across the project to allow the registry to not confuse them. |
# |
Jun 29th 2021, 14:33 |
kevin.pfeifer |
yes |
# |
Jun 29th 2021, 14:33 |
conehead |
that sucks :P |
# |
Jun 29th 2021, 14:32 |
slackebot |
=> 'projects_projects', 'foreignKey' => 'parent_id', 'targetForeignKey' => 'child_id' ] );``` |
# |
Jun 29th 2021, 14:32 |
kevin.pfeifer |
i e.g. use that to create child and parent projects like that ``` $this->belongsToMany( 'ParentProjects', [ 'className' => 'AlfredProjects.Projects', 'joinTable' => 'projects_projects', 'foreignKey' => 'child_id', 'targetForeignKey' => 'parent_id' ] ); $this->belongsToMany( 'ChildProjects', [ 'className' => 'AlfredProjects.Projects', 'joinTable' |
# |
Jun 29th 2021, 14:32 |
conehead |
Ah...but that would mean in every conain I would have to use the Alias name as well? |
# |
Jun 29th 2021, 14:29 |
kevin.pfeifer |
the first parameter is the alias. see the example here where hasOne is used to join on addresses multiple times https://book.cakephp.org/4/en/orm/associations.html#hasone-associations |
# |
Jun 29th 2021, 14:27 |
dereuromark |
The alias is the name, so yes |
# |
Jun 29th 2021, 14:19 |
conehead |
It is not just for behaviors, but for associations as well. Can I set the alias directly when setting an association? According to the documentation it is not a possible key https://book.cakephp.org/4/en/orm/associations.html#belongstomany-associations |
# |
Jun 29th 2021, 14:18 |
erwane |
Autoanswer : pass the remember_me data in hidden field : https://github.com/andrej-griniuk/cakephp-two-factor-auth/issues/19 |
# |
Jun 29th 2021, 14:13 |
dereuromark |
i dont follow. how is setting it through manual table different? its both config. and couldn't this be adapted to some kind of auto-config flag? so it can work across all Tables then as improvement directly on the behavior? sounds useful if you extensively use it. |
# |
Jun 29th 2021, 14:10 |
conehead |
@dereuromark Guess tomorrow I will try to create my own table class that will automatically set the alias to $Alias$AssocName for each and every association. Setting in the config does work for your plugin, but won't work for other associations as the alias cannot be set there |
# |
Jun 29th 2021, 14:05 |
erwane |
hi, it's me again ;) I'm trying to configure TFA Authentication plugin (https://github.com/andrej-griniuk/cakephp-two-factor-auth) with the `CookieAuthenticator aka remember_me` The request loose the `remember_me` field in the intermediate check form and cookie is not set. Someone already has this issue ? |
# |
Jun 29th 2021, 13:51 |
slackebot |
a transaction yourself you will need to dispatch that event yourself too |
# |
Jun 29th 2021, 13:51 |
kevin.pfeifer |
this event is being dispatched by • `findOrCreate` https://github.com/cakephp/cakephp/blob/ab052da10dc5ceb2444c29aef838d10844fe5995/src/ORM/Table.php#L1624 • `save` https://github.com/cakephp/cakephp/blob/ab052da10dc5ceb2444c29aef838d10844fe5995/src/ORM/Table.php#L1875 • `saveMany` https://github.com/cakephp/cakephp/blob/ab052da10dc5ceb2444c29aef838d10844fe5995/src/ORM/Table.php#L2266 not anywhere else. So if you do |
# |
Jun 29th 2021, 13:44 |
birdy247 |
If saving inside a transaction, does the afterSaveCommit not get called? |
# |
Jun 29th 2021, 13:34 |
dereuromark |
I would do it in the init config, but yeah that sounds like it would solve it |
# |
Jun 29th 2021, 13:24 |
slackebot |
{ $this->addBehavior('Tag'); $this->Tags->setAlias($this->getAlias . 'Tags'); ...``` But I got a feeling it is not possible because if it was this easy, it would probably be already automatically in it? |
# |
Jun 29th 2021, 13:24 |
conehead |
Yes, that goes into the right direction. Although I don't see it as an issue of your plugin, but as an general Cake issue. Issue is even the wrong word. It is convenient the way it is described in the documentation, but it looks like duplicate assoc names can be used. @dereuromark Do you think it would solve the problem to override the alias for each Table? Something like this: ```public function initialize(array $config): void |
# |
Jun 29th 2021, 13:19 |
theblackbird.eu |
Okay i really think it's a problem with the htaccess because I can open any catalog on the server through the domain... But it's not cake releated so I'll look elswere, thank you all for help. |
# |
Jun 29th 2021, 13:12 |
dereuromark |
@conehead true. once you know more, feel free to update any docs here. So far I only know about https://github.com/dereuromark/cakephp-tags/tree/master/docs#multiple-tags-per-model docs, which kind of include the case of multiple such relations also across different tables then implicitly, but not explicitly (yet). |
# |
Jun 29th 2021, 13:11 |
theblackbird.eu |
`App.base` seems to work, no obvious side effects either |
# |
Jun 29th 2021, 13:07 |
theblackbird.eu |
I generate relative URLs using eg. `$this->Url->build('/')` |
# |
Jun 29th 2021, 13:06 |
ndm |
Try setting `App.base` to an empty string. No guarantee you're not running into side effects with that. |