Alloy Events

24 views
Skip to first unread message

DK

unread,
Nov 13, 2011, 3:37:15 PM11/13/11
to allo...@googlegroups.com
Hello Again,

Well, moving along nicely on project with Alloy.  Have integrated half a dozen plugins, added custom classes to App\Module to extend the App\ControllerAbstract class to support many custom methods and properties to be available to all my Module Controllers.  Things are really working sweet.  Kinda feel like I could even field some questions on this forums at this point ;)

However, now I am integrating some logic that will support multiple domains.  Each domain will cause many dynamic changes to the application.  I have built a URL class as a plugin to do the logic and now I need to effect the application (changing config values, locale info, file paths, etc).

I noticed that there are Alloy 'events' being registered in the code, and there is one at a perfect point for where I need to make some app changes.  It is in index.php at line 29:
$kernel->events()->trigger('boot_start');
which is just after all the plugins have been loaded.

I do not see any documentation about these events on the Alloy site.  I am assuming I can register a method from my Url class to be executed at this event, rather then me adding code to the index.php file to execute what I need.

If this makes sense, any clarification on using the 'events' with a plugin would be appreciated.  Thanks again.

Vance Lucas

unread,
Nov 14, 2011, 12:07:37 PM11/14/11
to allo...@googlegroups.com
Good to hear you're making such great progress with Alloy.

The events system basically has two ways of hooking onto events - "bind" and "addFilter". Bind just fires your code when the event is triggered, and addFilter uses the value that your callback returns, allowing you to modify a value with plugins before it is used.

A good example of how both events are used is with the native "Spot" plugin that ships with Alloy:

The both follow the form of (<hook_name>, <callback_name>, <callback>). The <callback> can be any valid PHP callback or closure (passes is_callable).

--
Vance Lucas
http://vancelucas.com
Reply all
Reply to author
Forward
0 new messages