Hi,
I know how to use them. The idea was to have something like
MyController {
beforeFilter () {
defineHook('myHook');
}
}
And in the plugin to have something like {
PluginController {
function addCustomLogicToHook(&$controller,$hook,$params){
}
}
so the requestAction("/bla/bla/addCustomLogicToHook") is filled
automagically in the hook
Check Tariq Sani's cheesecake, AppInit component and hitStats plugin,
you'll have a better idea of what I mean. Unfortunately is build on an
older version of cake, and second, I do not want to steal the code. I
am just wondering if anyone has a better approach.
http://debuggable.com/posts/welcome-to-the-dark-side-of-plugins-in-cakephp:480f4dd5-0eb8-4cab-aeb3-4796cbdd56cb
at : Plugin Callbacks / Hooks
The Felix's approach is to :
callHooks('myHook', null, $this); in the appropriate place, and then
to create a new file that contain the hookable functions, called
hooks.php, so that you no longer need to requestAction.
This resembles Tarique's approach but somewhat tariq's approach is
more intuitive.
this is somewhat required so that more complex event driven
programming can be done without using tens or hundreds of
requestAction. while requestAction is ok for a self-centric app, a
plugin oriented app that lacks hooks (at least in views and
controllers) is not a choice, especially if you expect 3'd parties to
cooperate. Is not that I can't manage without them, is that it would
be sweet to have it as a core feature (like we have Auth for example).
We can choose to, or not to use it, but would be great to have, so
that more projects can share code and more complex CMS and such can
rely on a standard way to hook things in.
Unfortunately, both solutions I found are outdated, and both only have
controllerHooks.
There is another option to use something like TiramisPHP promises
(unfortunately nuvole.org is empty), that would be "an implementation
of the Implicit Invocation Pattern structured around event handling
for loose coupling and high cohesion in your CakePHP logic;". Not sure
this actually works.
In the meantime I found this :
http://cakealot.com/2009/04/eventful-a-cakephp-event-system/
Seems interesting. Anyone tried It ?
I am aware that CakePHP is not event driven, but I'm trying to find a
way to pass over this and have at least some way to hook plugins based
on "events" in a proper nonhackerish way that in 2 month nobody not
even the original developer won't know how it actually works.
Or maybe I'm missing something, and there is an obious easier way to
do this which I do not yet see. Basically right I want to tell the
beforeFilter of a Posts controller to do a requestAction of a
plugin ... from the plugin. because if I have 20 plugins (actually
will be only 5 payment methods) will be a unellegant to disable all
the "requestAction"s when I want to disable certain plugins. Last time
as I said I used only cake's core and requestActions, but it feels
somewhat not right. And I'm sure somebody out there had the same
problems, would be nice to see their thoughts/approaches to this and
even nicer to have cake have something like this included in the core
(like the AUTH component is).
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en