Re: Plugin callbacks and controller hooks

2009-12-20 Thread Walther
Here is an example: 
http://github.com/dakota/CMScout-Forums/blob/master/forums_events.php

As for the eventful plugin article, you should read it a bit more
carefully ;) At the bottom is a link to the plugin on github (http://
github.com/m3nt0r/eventful-cakephp)

It does work quite well, but was overkill for my purposes.

On Dec 19, 2:02 pm, Aargh dra...@secured.ro wrote:
 10x , looks great. Still your plugins folder is empty. Would be great
 to see how a (very simple) event plugin looks like. Anyway, I
 downloaded the source code and I'll mess around with it. As expected,
 as soon as you need more than messing arround with some db tables, you
 also need some kind of event driven approach, so I'm not the only one
 having this problem.
 Do you also plan to create some viewHooks so that the plugins will not
 only have own views and inject custom logic into the controllers, but
 also inject custom elements/views in the existing ones ?
 (This I've not seen implemented anywhere, although it looks like many
 CMS need this also).

 Anyway, at first glance it looks like a fine approach (especially that
 you're not only limited to standard controller callbacks).

 I also readhttp://cakealot.com/2009/04/eventful-a-cakephp-event-system/
 . Good article. But it looked more like a proof of concept to me,
 rather than a fully featured production ready implementation (m3nt0r
 is still working on this, as far as I understand). This is why I was
 searching for something more real life ready implementation, already
 tested by others.

 10x a lot for sharing this. I also seen that you're using debug kit.
 Everytime I look around here in the community I learn something new. I
 never knew it existed, looks great (... downloading it right now).

 On Dec 19, 8:47 am, Walther waltherl...@gmail.com wrote:

  I have done something similar for a CMS that I am busy writing.

  First look here:http://cakealot.com/2009/04/eventful-a-cakephp-event-system/
  That was my inspiration.

  Then look here:http://github.com/dakota/CMScout/tree/master/controllers/
  That is my event component. Basically, each plugin has a single
  plugin_name_events.php file which has all the events in.

  On Dec 18, 11:41 pm, Aargh dra...@secured.ro wrote:

   In the mean time i found this :

  http://teknoid.wordpress.com/2009/08/10/observer-pattern-the-cakephp-way

   Should be easy following the same idea to make the interesting apps
   controllers observable, the interested plugin controllers
   observers, and based on some observers's side config to initialise
   the correct $observers array in every observed controller. Anyway, I'm
   just messing arround, to find a decent solution. SpliceIt looks cool.
   To bad is unmantained.

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Plugin callbacks and controller hooks

2009-12-19 Thread Aargh
10x , looks great. Still your plugins folder is empty. Would be great
to see how a (very simple) event plugin looks like. Anyway, I
downloaded the source code and I'll mess around with it. As expected,
as soon as you need more than messing arround with some db tables, you
also need some kind of event driven approach, so I'm not the only one
having this problem.
Do you also plan to create some viewHooks so that the plugins will not
only have own views and inject custom logic into the controllers, but
also inject custom elements/views in the existing ones ?
(This I've not seen implemented anywhere, although it looks like many
CMS need this also).

Anyway, at first glance it looks like a fine approach (especially that
you're not only limited to standard controller callbacks).

I also read http://cakealot.com/2009/04/eventful-a-cakephp-event-system/
. Good article. But it looked more like a proof of concept to me,
rather than a fully featured production ready implementation (m3nt0r
is still working on this, as far as I understand). This is why I was
searching for something more real life ready implementation, already
tested by others.

10x a lot for sharing this. I also seen that you're using debug kit.
Everytime I look around here in the community I learn something new. I
never knew it existed, looks great (... downloading it right now).

On Dec 19, 8:47 am, Walther waltherl...@gmail.com wrote:
 I have done something similar for a CMS that I am busy writing.

 First look here:http://cakealot.com/2009/04/eventful-a-cakephp-event-system/
 That was my inspiration.

 Then look here:http://github.com/dakota/CMScout/tree/master/controllers/
 That is my event component. Basically, each plugin has a single
 plugin_name_events.php file which has all the events in.

 On Dec 18, 11:41 pm, Aargh dra...@secured.ro wrote:

  In the mean time i found this :

 http://teknoid.wordpress.com/2009/08/10/observer-pattern-the-cakephp-way

  Should be easy following the same idea to make the interesting apps
  controllers observable, the interested plugin controllers
  observers, and based on some observers's side config to initialise
  the correct $observers array in every observed controller. Anyway, I'm
  just messing arround, to find a decent solution. SpliceIt looks cool.
  To bad is unmantained.

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Plugin callbacks and controller hooks

2009-12-19 Thread Aargh
10x Jamie. Not sure which implementation to steal the ideas from
I'll choose. I'm not pressed by time, so I'll try your implementation
as well (most of the ideas I have in mind do not really need custom
placed hooks, before filter, after filter are just enough in 99
percent of the cases where you need controllerHooks. Though in 90
percent of the cases cakephp apps do not even need hooks, so you never
know).

I'm also testing the debug kit. Are there any other cool tools/
components like these out there that you guys use and I'm not aware
of ?
Any other opensource Cms's ? Cause What is in cakeforge is rather old
and outdated, and mambo5 is starting to look more and more like
vaporware.



On Dec 19, 9:49 am, Jamie jamie@gmail.com wrote:
 To add to the options already presented:

 I wrote a Plugin Callback component that executes callbacks in special
 plugin callback classes:

 http://jamienay.com/2009/11/an-easy-plugin-callback-component-for-cak...

 This works well for the large-scale CMS I built at work. Walther's
 solution also looks pretty cool, especially since his is geared
 towards custom hooks rather than just hooking on to existing
 controller callbacks.

 - Jamie

 On Dec 18, 4:53 am, Aargh dra...@secured.ro wrote:

  I would like to know if there is any official (or at least supported /
  under development) mechanism that would allow me to create hooks so
  that i can hook certain plugin functions into a controller.

  What would be sweet :

  Controller hooks

  For example let-s say we have a two statistics plugins. One checks the
  ip, one checks the searchphrase. They both basically work with the
  same data, and could be hooked into the afterFilter or smth.

  So the idea would be to be able to register a hook, and then (using
  naming conventions ??), certain (plugin) functions to be called.

  View hooks

  Would be great such thing to also exist for the views, let-s say we
  register a viewHook called product_addons, so if we develop a rate
  the product plugin, the view would take a ctp from the plugin and
  render the stars and the rating form in that hook. And of course when
  disabling the plugin, searching for the things to be rendered there
  will return empty. Whatever.

  I've seen something like (controllerHooks) this at Tarique Sani's
  Cheesecake, in his hitStats plugin. It has some AppInit component that
  will do the hooks. I'm not sure how it works, I've not investgated
  further as the software seems to be quite old (1.1 framework version I
  think). There was another implementation like this called SpliceIt,
  but is not mantained, and seems quite old also.

  Is there any reccomended way of actually plugging/unplugging custom
  logic ? Because the plugins seem more like separate apps (that can use
  the main's app logic, and not the other way arround, which is ok after
  all) to me. Maybe I missed something, but I can't find a way to
  elegantly plug in/out custom logic into the controllers.

  For plugging in/out custom elements/views i didn't find anything :(.

  Probably doing this in models is wrong by design.

  Maybe I have some brain damage from other apps I modified. But there
  are plenty of components and helpers that make development a breeze,
  until you need to actually do a plugin that can also easly plug out.
  This is one of the reasons I think apps like wordpress, prestashop and
  similar have a bigger community than any cakephp based app outhere
  (for example CheeseCake is a good photoblog, but without other (spam
  filtering for example) plugins is not to be considered by most
  photographers out there, and noone is willing to create one if there
  is no standard way to develop plugins in cakphp, and everytime you
  have to rediscover how the developer implemented the hooks). I think
  this would make easier for us to port plugins from one app to another,
  thus making creation of feature rich software easier.

  Is very hard to do anything but custom software on cakephp, as for
  example creating a good shopping cart will essentially rule out 3'rd
  parties from developing payment or shipping plugins. Most of those
  payment plugins for example do the same thing, but using different
  apis. From the cart's point of view they all act the same, send a
  form, receive an answer, update the cart's status. But there is no
  elegant way to plug in/out these modules. And the funny thing is most
  of them do not even need a table, just a form and a way to validate
  the answer and change cart's status.

  Some time ago I developed some publishing software with cake (1.1). It
  was great, until it came to statistics. I had to add lots of
  requestActions in the before and afterFilters. Right now is some kind
  of mess (as removong a plugin would also mean to remove the added
  logic into the main apps controllers and views). The next thing I
  develop I would like to not become so messy.

  (Btw, sluggable behaviour, bindable behaviour, meio upload and 

Plugin callbacks and controller hooks

2009-12-18 Thread Aargh
I would like to know if there is any official (or at least supported /
under development) mechanism that would allow me to create hooks so
that i can hook certain plugin functions into a controller.

What would be sweet :

Controller hooks

For example let-s say we have a two statistics plugins. One checks the
ip, one checks the searchphrase. They both basically work with the
same data, and could be hooked into the afterFilter or smth.

So the idea would be to be able to register a hook, and then (using
naming conventions ??), certain (plugin) functions to be called.

View hooks

Would be great such thing to also exist for the views, let-s say we
register a viewHook called product_addons, so if we develop a rate
the product plugin, the view would take a ctp from the plugin and
render the stars and the rating form in that hook. And of course when
disabling the plugin, searching for the things to be rendered there
will return empty. Whatever.

I've seen something like (controllerHooks) this at Tarique Sani's
Cheesecake, in his hitStats plugin. It has some AppInit component that
will do the hooks. I'm not sure how it works, I've not investgated
further as the software seems to be quite old (1.1 framework version I
think). There was another implementation like this called SpliceIt,
but is not mantained, and seems quite old also.

Is there any reccomended way of actually plugging/unplugging custom
logic ? Because the plugins seem more like separate apps (that can use
the main's app logic, and not the other way arround, which is ok after
all) to me. Maybe I missed something, but I can't find a way to
elegantly plug in/out custom logic into the controllers.

For plugging in/out custom elements/views i didn't find anything :(.

Probably doing this in models is wrong by design.

Maybe I have some brain damage from other apps I modified. But there
are plenty of components and helpers that make development a breeze,
until you need to actually do a plugin that can also easly plug out.
This is one of the reasons I think apps like wordpress, prestashop and
similar have a bigger community than any cakephp based app outhere
(for example CheeseCake is a good photoblog, but without other (spam
filtering for example) plugins is not to be considered by most
photographers out there, and noone is willing to create one if there
is no standard way to develop plugins in cakphp, and everytime you
have to rediscover how the developer implemented the hooks). I think
this would make easier for us to port plugins from one app to another,
thus making creation of feature rich software easier.

Is very hard to do anything but custom software on cakephp, as for
example creating a good shopping cart will essentially rule out 3'rd
parties from developing payment or shipping plugins. Most of those
payment plugins for example do the same thing, but using different
apis. From the cart's point of view they all act the same, send a
form, receive an answer, update the cart's status. But there is no
elegant way to plug in/out these modules. And the funny thing is most
of them do not even need a table, just a form and a way to validate
the answer and change cart's status.

Some time ago I developed some publishing software with cake (1.1). It
was great, until it came to statistics. I had to add lots of
requestActions in the before and afterFilters. Right now is some kind
of mess (as removong a plugin would also mean to remove the added
logic into the main apps controllers and views). The next thing I
develop I would like to not become so messy.

(Btw, sluggable behaviour, bindable behaviour, meio upload and magick
resize helper spared me a lot of work, 10x god the community is
strugling to add cool functionality to the framework).

I searched about this topics, but I didn't find much. I checked
various apps for ideas, but most of them are outdated.

Is there anything like this in plan ? Is there any component that
already do that ?

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Plugin callbacks and controller hooks

2009-12-18 Thread robustsolution
AFAIK,

plugin could be used

-1-to be a ~~~separate application : example the blog plugin, the auth
plugin, the forum plugin, etc...
-2-to be called from anywhere by using a requestAction: example
captcha plugin is used to be called via requestAction to import the
prove that you are human image

choose the option you need (you may use number 2)

and have a nice baking day


On Dec 18, 12:53 pm, Aargh dra...@secured.ro wrote:
 I would like to know if there is any official (or at least supported /
 under development) mechanism that would allow me to create hooks so
 that i can hook certain plugin functions into a controller.

 What would be sweet :

 Controller hooks

 For example let-s say we have a two statistics plugins. One checks the
 ip, one checks the searchphrase. They both basically work with the
 same data, and could be hooked into the afterFilter or smth.

 So the idea would be to be able to register a hook, and then (using
 naming conventions ??), certain (plugin) functions to be called.

 View hooks

 Would be great such thing to also exist for the views, let-s say we
 register a viewHook called product_addons, so if we develop a rate
 the product plugin, the view would take a ctp from the plugin and
 render the stars and the rating form in that hook. And of course when
 disabling the plugin, searching for the things to be rendered there
 will return empty. Whatever.

 I've seen something like (controllerHooks) this at Tarique Sani's
 Cheesecake, in his hitStats plugin. It has some AppInit component that
 will do the hooks. I'm not sure how it works, I've not investgated
 further as the software seems to be quite old (1.1 framework version I
 think). There was another implementation like this called SpliceIt,
 but is not mantained, and seems quite old also.

 Is there any reccomended way of actually plugging/unplugging custom
 logic ? Because the plugins seem more like separate apps (that can use
 the main's app logic, and not the other way arround, which is ok after
 all) to me. Maybe I missed something, but I can't find a way to
 elegantly plug in/out custom logic into the controllers.

 For plugging in/out custom elements/views i didn't find anything :(.

 Probably doing this in models is wrong by design.

 Maybe I have some brain damage from other apps I modified. But there
 are plenty of components and helpers that make development a breeze,
 until you need to actually do a plugin that can also easly plug out.
 This is one of the reasons I think apps like wordpress, prestashop and
 similar have a bigger community than any cakephp based app outhere
 (for example CheeseCake is a good photoblog, but without other (spam
 filtering for example) plugins is not to be considered by most
 photographers out there, and noone is willing to create one if there
 is no standard way to develop plugins in cakphp, and everytime you
 have to rediscover how the developer implemented the hooks). I think
 this would make easier for us to port plugins from one app to another,
 thus making creation of feature rich software easier.

 Is very hard to do anything but custom software on cakephp, as for
 example creating a good shopping cart will essentially rule out 3'rd
 parties from developing payment or shipping plugins. Most of those
 payment plugins for example do the same thing, but using different
 apis. From the cart's point of view they all act the same, send a
 form, receive an answer, update the cart's status. But there is no
 elegant way to plug in/out these modules. And the funny thing is most
 of them do not even need a table, just a form and a way to validate
 the answer and change cart's status.

 Some time ago I developed some publishing software with cake (1.1). It
 was great, until it came to statistics. I had to add lots of
 requestActions in the before and afterFilters. Right now is some kind
 of mess (as removong a plugin would also mean to remove the added
 logic into the main apps controllers and views). The next thing I
 develop I would like to not become so messy.

 (Btw, sluggable behaviour, bindable behaviour, meio upload and magick
 resize helper spared me a lot of work, 10x god the community is
 strugling to add cool functionality to the framework).

 I searched about this topics, but I didn't find much. I checked
 various apps for ideas, but most of them are outdated.

 Is there anything like this in plan ? Is there any component that
 already do that ?

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Plugin callbacks and controller hooks

2009-12-18 Thread robustsolution
m sorry, captcha plugin is also considered as a very small separate
application plugin, I gave a wrong example.

but you still have the option number 2 but you need to specify the
plugin key/prefix in the url array/string


On Dec 18, 1:54 pm, robustsolution i...@robustsolution.net wrote:
 AFAIK,

 plugin could be used

 -1-to be a ~~~separate application : example the blog plugin, the auth
 plugin, the forum plugin, etc...
 -2-to be called from anywhere by using a requestAction: example
 captcha plugin is used to be called via requestAction to import the
 prove that you are human image

 choose the option you need (you may use number 2)

 and have a nice baking day

 On Dec 18, 12:53 pm, Aargh dra...@secured.ro wrote:

  I would like to know if there is any official (or at least supported /
  under development) mechanism that would allow me to create hooks so
  that i can hook certain plugin functions into a controller.

  What would be sweet :

  Controller hooks

  For example let-s say we have a two statistics plugins. One checks the
  ip, one checks the searchphrase. They both basically work with the
  same data, and could be hooked into the afterFilter or smth.

  So the idea would be to be able to register a hook, and then (using
  naming conventions ??), certain (plugin) functions to be called.

  View hooks

  Would be great such thing to also exist for the views, let-s say we
  register a viewHook called product_addons, so if we develop a rate
  the product plugin, the view would take a ctp from the plugin and
  render the stars and the rating form in that hook. And of course when
  disabling the plugin, searching for the things to be rendered there
  will return empty. Whatever.

  I've seen something like (controllerHooks) this at Tarique Sani's
  Cheesecake, in his hitStats plugin. It has some AppInit component that
  will do the hooks. I'm not sure how it works, I've not investgated
  further as the software seems to be quite old (1.1 framework version I
  think). There was another implementation like this called SpliceIt,
  but is not mantained, and seems quite old also.

  Is there any reccomended way of actually plugging/unplugging custom
  logic ? Because the plugins seem more like separate apps (that can use
  the main's app logic, and not the other way arround, which is ok after
  all) to me. Maybe I missed something, but I can't find a way to
  elegantly plug in/out custom logic into the controllers.

  For plugging in/out custom elements/views i didn't find anything :(.

  Probably doing this in models is wrong by design.

  Maybe I have some brain damage from other apps I modified. But there
  are plenty of components and helpers that make development a breeze,
  until you need to actually do a plugin that can also easly plug out.
  This is one of the reasons I think apps like wordpress, prestashop and
  similar have a bigger community than any cakephp based app outhere
  (for example CheeseCake is a good photoblog, but without other (spam
  filtering for example) plugins is not to be considered by most
  photographers out there, and noone is willing to create one if there
  is no standard way to develop plugins in cakphp, and everytime you
  have to rediscover how the developer implemented the hooks). I think
  this would make easier for us to port plugins from one app to another,
  thus making creation of feature rich software easier.

  Is very hard to do anything but custom software on cakephp, as for
  example creating a good shopping cart will essentially rule out 3'rd
  parties from developing payment or shipping plugins. Most of those
  payment plugins for example do the same thing, but using different
  apis. From the cart's point of view they all act the same, send a
  form, receive an answer, update the cart's status. But there is no
  elegant way to plug in/out these modules. And the funny thing is most
  of them do not even need a table, just a form and a way to validate
  the answer and change cart's status.

  Some time ago I developed some publishing software with cake (1.1). It
  was great, until it came to statistics. I had to add lots of
  requestActions in the before and afterFilters. Right now is some kind
  of mess (as removong a plugin would also mean to remove the added
  logic into the main apps controllers and views). The next thing I
  develop I would like to not become so messy.

  (Btw, sluggable behaviour, bindable behaviour, meio upload and magick
  resize helper spared me a lot of work, 10x god the community is
  strugling to add cool functionality to the framework).

  I searched about this topics, but I didn't find much. I checked
  various apps for ideas, but most of them are outdated.

  Is there anything like this in plan ? Is there any component that
  already do that ?

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 

Re: Plugin callbacks and controller hooks

2009-12-18 Thread Aargh
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 requestActions 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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Plugin callbacks and controller hooks

2009-12-18 Thread Miles J
I don't see why you just don't use the callbacks?

On Dec 18, 8:04 am, Aargh dra...@secured.ro wrote:
 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-ca...

 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 requestActions 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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Plugin callbacks and controller hooks

2009-12-18 Thread Aargh
I already used them. Right now I am starting a new project, which I
would like to opensource, so other developers can write plugins
without messing with the core app. So instead of to install this
plugin add x lines in the user controller file in before filter
function and y lines in the posts controller file, the plugin to have
some (predefined) hooks. This usually means a event driven approach.
And most of the more featured cake apps out there have aldeady
somewhat implemented this. I'm just looking around for the best
approach to this kind of functionality. Of course this can be done
instantiating a list of the plugins and then execute in the
BeforeFilter() the the functions that start with BeforeFilter in a
certain hooks.php file in every plugin directory. Quick and dirty, and
it works. But I am looking for a more elegant solution.


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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Plugin callbacks and controller hooks

2009-12-18 Thread Aargh
In the mean time i found this :

http://teknoid.wordpress.com/2009/08/10/observer-pattern-the-cakephp-way

Should be easy following the same idea to make the interesting apps
controllers observable, the interested plugin controllers
observers, and based on some observers's side config to initialise
the correct $observers array in every observed controller. Anyway, I'm
just messing arround, to find a decent solution. SpliceIt looks cool.
To bad is unmantained.

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Plugin callbacks and controller hooks

2009-12-18 Thread Walther
I have done something similar for a CMS that I am busy writing.

First look here: http://cakealot.com/2009/04/eventful-a-cakephp-event-system/
That was my inspiration.

Then look here: http://github.com/dakota/CMScout/tree/master/controllers/
That is my event component. Basically, each plugin has a single
plugin_name_events.php file which has all the events in.

On Dec 18, 11:41 pm, Aargh dra...@secured.ro wrote:
 In the mean time i found this :

 http://teknoid.wordpress.com/2009/08/10/observer-pattern-the-cakephp-way

 Should be easy following the same idea to make the interesting apps
 controllers observable, the interested plugin controllers
 observers, and based on some observers's side config to initialise
 the correct $observers array in every observed controller. Anyway, I'm
 just messing arround, to find a decent solution. SpliceIt looks cool.
 To bad is unmantained.

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Plugin callbacks and controller hooks

2009-12-18 Thread Jamie
To add to the options already presented:

I wrote a Plugin Callback component that executes callbacks in special
plugin callback classes:

http://jamienay.com/2009/11/an-easy-plugin-callback-component-for-cakephp-1-2/

This works well for the large-scale CMS I built at work. Walther's
solution also looks pretty cool, especially since his is geared
towards custom hooks rather than just hooking on to existing
controller callbacks.

- Jamie


On Dec 18, 4:53 am, Aargh dra...@secured.ro wrote:
 I would like to know if there is any official (or at least supported /
 under development) mechanism that would allow me to create hooks so
 that i can hook certain plugin functions into a controller.

 What would be sweet :

 Controller hooks

 For example let-s say we have a two statistics plugins. One checks the
 ip, one checks the searchphrase. They both basically work with the
 same data, and could be hooked into the afterFilter or smth.

 So the idea would be to be able to register a hook, and then (using
 naming conventions ??), certain (plugin) functions to be called.

 View hooks

 Would be great such thing to also exist for the views, let-s say we
 register a viewHook called product_addons, so if we develop a rate
 the product plugin, the view would take a ctp from the plugin and
 render the stars and the rating form in that hook. And of course when
 disabling the plugin, searching for the things to be rendered there
 will return empty. Whatever.

 I've seen something like (controllerHooks) this at Tarique Sani's
 Cheesecake, in his hitStats plugin. It has some AppInit component that
 will do the hooks. I'm not sure how it works, I've not investgated
 further as the software seems to be quite old (1.1 framework version I
 think). There was another implementation like this called SpliceIt,
 but is not mantained, and seems quite old also.

 Is there any reccomended way of actually plugging/unplugging custom
 logic ? Because the plugins seem more like separate apps (that can use
 the main's app logic, and not the other way arround, which is ok after
 all) to me. Maybe I missed something, but I can't find a way to
 elegantly plug in/out custom logic into the controllers.

 For plugging in/out custom elements/views i didn't find anything :(.

 Probably doing this in models is wrong by design.

 Maybe I have some brain damage from other apps I modified. But there
 are plenty of components and helpers that make development a breeze,
 until you need to actually do a plugin that can also easly plug out.
 This is one of the reasons I think apps like wordpress, prestashop and
 similar have a bigger community than any cakephp based app outhere
 (for example CheeseCake is a good photoblog, but without other (spam
 filtering for example) plugins is not to be considered by most
 photographers out there, and noone is willing to create one if there
 is no standard way to develop plugins in cakphp, and everytime you
 have to rediscover how the developer implemented the hooks). I think
 this would make easier for us to port plugins from one app to another,
 thus making creation of feature rich software easier.

 Is very hard to do anything but custom software on cakephp, as for
 example creating a good shopping cart will essentially rule out 3'rd
 parties from developing payment or shipping plugins. Most of those
 payment plugins for example do the same thing, but using different
 apis. From the cart's point of view they all act the same, send a
 form, receive an answer, update the cart's status. But there is no
 elegant way to plug in/out these modules. And the funny thing is most
 of them do not even need a table, just a form and a way to validate
 the answer and change cart's status.

 Some time ago I developed some publishing software with cake (1.1). It
 was great, until it came to statistics. I had to add lots of
 requestActions in the before and afterFilters. Right now is some kind
 of mess (as removong a plugin would also mean to remove the added
 logic into the main apps controllers and views). The next thing I
 develop I would like to not become so messy.

 (Btw, sluggable behaviour, bindable behaviour, meio upload and magick
 resize helper spared me a lot of work, 10x god the community is
 strugling to add cool functionality to the framework).

 I searched about this topics, but I didn't find much. I checked
 various apps for ideas, but most of them are outdated.

 Is there anything like this in plan ? Is there any component that
 already do that ?

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en