# |
Feb 25th 2018, 14:28 |
spriz |
Ah true. |
# |
Feb 25th 2018, 14:28 |
hmic |
but that again only works, if your controller does not have it too |
# |
Feb 25th 2018, 14:28 |
muerte |
but now I change to Plugin::load('Calendar.Calendar'); |
# |
Feb 25th 2018, 14:28 |
hmic |
thats the other solution spritz, have implementedEvents in the trait |
# |
Feb 25th 2018, 14:27 |
muerte |
sorry I add Plugin::load('Calendar'); |
# |
Feb 25th 2018, 14:27 |
dereuromark |
muerte: but is written there black on white - directly at the beginning |
# |
Feb 25th 2018, 14:27 |
spriz |
other names fixed it :slightly_smiling_face: https://gist.github.com/Spriz/efa8a9a774bf20fd3b7737eff679e2bd |
# |
Feb 25th 2018, 14:26 |
spriz |
Sure is my fault :) |
# |
Feb 25th 2018, 14:26 |
muerte |
no, I not add anything to bootstrap |
# |
Feb 25th 2018, 14:25 |
dereuromark |
muerte: i meant if you loaded it properly in your bootstrap |
# |
Feb 25th 2018, 14:25 |
hmic |
or you implement a baseclass to use like in the php example (just put the stub baseclass in the same file and extend it on the spot) |
# |
Feb 25th 2018, 14:24 |
hmic |
spritz: your fault :P traits dont automagically execute some setup functionality so you would need implementedEvents (and make sure your controller does not have it either) in the trait |
# |
Feb 25th 2018, 14:24 |
muerte |
I add this in Template/Users/index.ctp |
# |
Feb 25th 2018, 14:23 |
muerte |
https://gist.github.com/anonymous/9f4ad078ffaa9f3bba6327b4a020f728 |
# |
Feb 25th 2018, 14:21 |
muerte |
is in doc |
# |
Feb 25th 2018, 14:21 |
muerte |
$this->loadComponent('Calendar.Calendar'); |
# |
Feb 25th 2018, 14:21 |
muerte |
Load the component in your controller: |
# |
Feb 25th 2018, 14:20 |
spriz |
@hmic: Problem is that I actually do like: https://3v4l.org/Iji4v ,:( |
# |
Feb 25th 2018, 14:19 |
muerte |
documented? |
# |
Feb 25th 2018, 14:16 |
dereuromark |
did you load the plugin as documented? |
# |
Feb 25th 2018, 14:14 |
muerte |
where should I put loadComponent to load this component? |
# |
Feb 25th 2018, 14:11 |
muerte |
and component not load? |
# |
Feb 25th 2018, 14:11 |
muerte |
I add loadComponent to AppController.php https://gist.github.com/anonymous/b3b6aa97ce56c3572bc46eb66a2d9814 |
# |
Feb 25th 2018, 14:07 |
muerte |
and i still have error: You need to load Calendar.Calendar component for this helper to work. |
# |
Feb 25th 2018, 14:06 |
muerte |
a try add plugin to my app https://github.com/dereuromark/cakephp-calendar |
# |
Feb 25th 2018, 14:05 |
muerte |
hi |
# |
Feb 25th 2018, 13:58 |
spriz |
thanks a lot! |
# |
Feb 25th 2018, 13:58 |
spriz |
didn’t think of having parent:: in trait :,) |
# |
Feb 25th 2018, 13:58 |
hmic |
;) |
# |
Feb 25th 2018, 13:58 |
spriz |
do’h |
# |
Feb 25th 2018, 13:58 |
spriz |
Ahh ofc |
# |
Feb 25th 2018, 13:58 |
spriz |
I could easily achieve it by using `$this->activateMethodFromTrait()` somewhere but I’d avoid that |
# |
Feb 25th 2018, 13:57 |
hmic |
the second example is exactly that usecase |
# |
Feb 25th 2018, 13:57 |
hmic |
http://php.net/manual/en/language.oop5.traits.php |
# |
Feb 25th 2018, 13:57 |
hmic |
so if you have just that method in your trait too, you can call parent:: in there i suppose |
# |
Feb 25th 2018, 13:56 |
hmic |
the default is not an event. the default is just a method in your controller that gets called. |
# |
Feb 25th 2018, 13:55 |
spriz |
and I’d like to call another method after that, without doing anything but including the `Use TheTrait;` |
# |
Feb 25th 2018, 13:54 |
spriz |
because 1 is the default `Controller.Initialize’ => ‘beforeFilter’` |
# |
Feb 25th 2018, 13:52 |
hmic |
why 2 different listeners? |
# |
Feb 25th 2018, 13:50 |
spriz |
What’s the smartest way to register 2 listeners to the same event? :thinking_face: :thinking_face: Use case: I have a trait included in controllers, and I would like to hook into the beforeFilter method. |
# |
Feb 25th 2018, 10:15 |
Sigfried84 |
Good morning! Does a model authors_author_types_books work? |