Events

FlowBasis provides a publish/subsribe mechanism for events within the system (see FlowBasis::getEventManager() and FlowBasis_Events_EventManager). Any system or custom component can raise an event by calling FlowBasis::getEventManager()->raiseEvent($eventName, $eventData), where $eventName is used to route the event to interested parties and $eventData is any object which can hold extra information about the event.

An example of an event name is "FlowBasis/Accounts/AccountManager/userLogin/someuser" (where "someuser" would be the username of the user who logged in). The event data associated with the userAccountCreated event includes a timestamp and the userData for the account. Any subscriber with a subscription for any of the following event names will receive the event:

  • "" (all events)
  • "FlowBasis"
  • "FlowBasis/Accounts"
  • "FlowBasis/Accounts/AccountManager"
  • "FlowBasis/Accounts/AccountManager/userLogin"
  • "FlowBasis/Accounts/AccountManager/userLogin/someuser"

Subscribers register their interest in an event with FlowBasis::getEventManager()->subscribe($eventName, $subscriberData). For an example of how to define $subscriberData, see the FlowBasis Online Users plugin (in core-classes/FlowBasis/Plugins/OnlineUsers/OnlineUserManager.php: register/unregister methods).

Events Defined by FlowBasis

eventName: FlowBasis/Accounts/AccountManager/userAccountCreated
eventData: { timestamp, userData }

eventName: FlowBasis/Accounts/AccountManager/userAccountModified
eventData: { timestamp, username, updateUserDataObject }

eventName: FlowBasis/Accounts/AccountManager/userLogin/<username>
eventData: { timestamp, username, loginStats }

eventName: FlowBasis/Accounts/AccountManager/userLogout/<username>
eventData: { timestamp, username }

eventName: FlowBasis/Accounts/AccountManager/userPageRequest/<username>
eventData: { timestamp, username, fullSitePath }

eventName: FlowBasis/Comments/CommentManager/commentAdded/<resourceID>
eventData: { timestamp, resourceID, commentData }

eventName: FlowBasis/Comments/CommentManager/commentUpdated/<resourceID>
eventData: { timestamp, resourceID, commentID}

eventName: FlowBasis/Ratings/RatingsManager/resourceRated/<resourceID>
eventData: { timestamp, resourceID, username, newRating }

Possible Uses for Events

Text Message Notification - Create a component that subscribes to key events and forwards them to a mobile phone via a text message.

User Scoring - Subscribe to events for added comments and rating resources to dynamically update a user score based on user activity.

Global Event Logger

FlowBasis includes a global event logger that can be enabled for debugging purposes (though it is definitely not recommended to run your site live with it enabled). You can enable the global event logger by logging in as an admin user, going to /admin/developers/ and enabling global event logger in the property grid. The events will be logged to FlowBasis::getDataRoot() . '/logs/FlowBasis/log' which can be monitored with "tail -f".