# |
Jul 14th 2021, 15:59 |
tyler.adam.lazenby |
I was so confused |
# |
Jul 14th 2021, 15:59 |
cnizzardini |
oops wrong chat |
# |
Jul 14th 2021, 15:57 |
cnizzardini |
Did you try this instead: |
# |
Jul 14th 2021, 10:01 |
eax |
Found that solution on github not three minutes ago :P |
# |
Jul 14th 2021, 10:01 |
eax |
Thanks @matsaku! I ended up doing. this instead: `$this->ModelName->getEventManager()->off('Model.beforeSave');` |
# |
Jul 14th 2021, 09:55 |
kevin.pfeifer |
you can pass a custom option to your ```$articles->save($article, ['doNotBeforeSave' => false]);``` and check in your `beforeSave(EventInterface $event*,* EntityInterface $entity*,* ArrayObject $options)` function if that option is set and then just return true like ```if(!empty($options['doNotBeforeSave']) andand $options['doNotBeforeSave']) return true;``` |
# |
Jul 14th 2021, 09:46 |
eax |
Hey folks! Cake3 question: Can I disable a beforeSave event from a model somehow? I looked at the examples in the Cookbook but couldn’t make sense of how to apply them here :$ |
# |
Jul 14th 2021, 08:14 |
rudy1976s |
the listeners is set up in a plugin, I forgot to mention and it is loaded in the plugin.php of the plugin |
# |
Jul 14th 2021, 08:14 |
rudy1976s |
hello all ! I have a problem related to events that I was not yet able to manage: I have a controller action where I create an event and dispatch it: i cannot figure out why it randomly fires; i have a listener registered to that event. In the same controller I have another event, in another action which fires every time without any issue. |
# |
Jul 14th 2021, 07:19 |
dereuromark |
The existing alternatives are listed in https://github.com/FriendsOfCake/awesome-cakephp#queue |
# |
Jul 14th 2021, 07:17 |
dereuromark |
@gautam If you googled, and didnt find anything but that old core ticket, then the answer is most likely "not yet", but you could easily find existing libs out there (e.g. google finds https://github.com/lanlin/codeigniter-swoole ) and you could quickly port this to CakePHP and create a plugin for it yourself. |
# |
Jul 14th 2021, 03:53 |
hmic |
You will need to load the data yourself |
# |
Jul 14th 2021, 03:31 |
gautam |
Do we have any integration of swoole with cakephp? |
# |
Jul 14th 2021, 03:04 |
admad |
If the entity doesn't already have the related record you obviously need to load it yourself. |
# |
Jul 13th 2021, 23:20 |
rightscoreanalysis |
or do I have to load the model in the event and do a findbyid? |
# |
Jul 13th 2021, 22:55 |
rightscoreanalysis |
is this possible? |
# |
Jul 13th 2021, 22:55 |
rightscoreanalysis |
eg $entity->foo->title, but of course the entity only has foo_id |
# |
Jul 13th 2021, 22:54 |
rightscoreanalysis |
I have an event listener setup on my model save, but I need the title attribute of a related model... |
# |
Jul 13th 2021, 20:40 |
kevin.pfeifer |
would be a nice addition to https://book.cakephp.org/migrations/2/en/index.html |
# |
Jul 13th 2021, 20:39 |
greg138 |
I don't know if it's in the docs. It's in my code, but it might have gotten there by me searching the source, not the docs. :) |
# |
Jul 13th 2021, 20:20 |
dereuromark |
if this isnt in the docs, maybe it should be :) |
# |
Jul 13th 2021, 19:11 |
greg138 |
`$migrations = new \Migrations\Migrations();` `$migrations->seed(['plugin' => 'MyPlugin', 'seed' => 'MySeed']);` |
# |
Jul 13th 2021, 19:05 |
richard |
makes my life easier |
# |
Jul 13th 2021, 19:05 |
richard |
what i do is create a masterseed that runs all the other seeds, i also have checks in each seed so re-running won’t produce duplicate records |
# |
Jul 13th 2021, 18:28 |
devito |
is it possible to change the default layout of a plugin without modifying the plugin its self? |
# |
Jul 13th 2021, 17:48 |
tyler.adam.lazenby |
yeah |
# |
Jul 13th 2021, 17:48 |
dereuromark |
genius :) I would probably still prefer to have also a more code native way to run them. Might be worth a PR some day for someone. |
# |
Jul 13th 2021, 17:47 |
tyler.adam.lazenby |
```public function runSeed($name) { exec(join(DS, ['bin', 'cake']) . " migrations seed --seed=$name"); }``` |
# |
Jul 13th 2021, 17:47 |
tyler.adam.lazenby |
for me this works fine |
# |
Jul 13th 2021, 17:34 |
tyler.adam.lazenby |
if this doesn't work |
# |
Jul 13th 2021, 17:34 |
tyler.adam.lazenby |
i might |
# |
Jul 13th 2021, 17:34 |
tyler.adam.lazenby |
hmmmmm |
# |
Jul 13th 2021, 17:33 |
kevin.pfeifer |
You could try to get some code snippets from https://github.com/cakephp/migrations/blob/master/src/AbstractSeed.php#L72 Which basically is the function to call one seed inside of another |
# |
Jul 13th 2021, 17:30 |
tyler.adam.lazenby |
nevermind |
# |
Jul 13th 2021, 17:30 |
tyler.adam.lazenby |
oh wait |
# |
Jul 13th 2021, 17:30 |
tyler.adam.lazenby |
and I can't call DS here |
# |
Jul 13th 2021, 17:29 |
tyler.adam.lazenby |
and the \ should be \ in windows but it should / on linux |
# |
Jul 13th 2021, 17:29 |
tyler.adam.lazenby |
the problem with that is that I am developing on windows for a machine that is in linux |
# |
Jul 13th 2021, 17:29 |
tyler.adam.lazenby |
the hax way huh? |
# |
Jul 13th 2021, 17:28 |
dereuromark |
exec() :P |
# |
Jul 13th 2021, 17:25 |
tyler.adam.lazenby |
is there a way to call seeds within a migration? |