Skip to content
cloudmanic edited this page Oct 21, 2012 · 2 revisions

Cloudmanic CMS has a basic events system built right in. This way you can add custom functionality to trigger at different points. For example you might want to clear a server cache every time you change the data in your CMS. You can listen for events such as "after.insert", "after.update", "after.delete". Upon these events clear the server cache. The sky is the limit. Typically you would register events before you bootstrap the CMS. You can put these events in the index.php or include another file with your events.

See the example below. This is what your index.php file could look like to support these events. Clearly you will want to do more than just echo the event data. But the echo statements is a good way to understand how things work.

require '../../vendor/autoload.php';

// This is called after an insert operation into a CMS table.
CMS\Libraries\Event::listen('after.insert', function($table, $id, $data) {
	echo "Inserted data into $table and returned $id <br />";
  echo '<pre>' . print_r($data, TRUE) . '</pre>';
});

// This is called after an update operation into a CMS table.
CMS\Libraries\Event::listen('after.update', function($table, $id, $data) {
	echo "Updated data of $table with $id<br />";
  echo '<pre>' . print_r($data, TRUE) . '</pre>';
});

// This is called after a delete operation into a CMS table.
CMS\Libraries\Event::listen('after.delete', function($table, $id) {
	echo "Data data in $table with $id<br />";
});

CMS::framework('laravel3', '../../application');
require CMS::boostrap('../../vendor');

Events we support.

  • after.insert - Fired after any data is inserted.
  • after.update - Fired after any data is updated.
  • after.delete - Fired after any data is deleted.
Clone this wiki locally