Skip to content
Noodlewitt edited this page Aug 26, 2015 · 20 revisions

Laravel's Events are used to implement Hooks are used to launch events on specific cms actions.

Registering event

You can register events by adding an event listener:

\Event::listen('content.update', function($object){
    //do stuff in here - $object will depend on what object you are handling.
});

Where to register event

You can add in an event listener wherever make most sense.. typically it'll be in the service provider constructor. Something like this:

class MyThemeServiceProvider extends ServiceProvider {

public function __construct($app) {
        parent::__construct($app);

        //TODO: REGISTER HOOKS FOR VARIIOS ACTIONS
        \Event::listen('content.update', function($user){
	    dd($user);
    });
    }
    //other service provider junk in here

List of possible hooks

  • content.update - run once before content update

  • content.updated - run once after content update

  • content.create - run once before content create

  • content.created - run once after content create

  • content.edit - run once before content create or update

  • content.edited - run once after content create or update

  • upload.complete - run after each file upload.

  • content.[input_type].draw - (content, setting) - run on draw of content input type.

  • routes.before - run before standard cms routing

  • routes.after - run after standard cms routing

  • menu.links - links in main cms menu

  • blog.post.types - content types for blog posts

  • blog.post.finish_update

  • blog.post.before_delete

  • search.reindex

..some html ones

  • html.master.header.start
  • html.master.header.end
  • html.bare.header.start
  • html.bare.header.start
  • html.body.start
  • html.body.end

..more to come soon

Clone this wiki locally