Really useful software project management and source code hosting.    tell me more...
BROWSE: projects / users / groups
CakePHP component that adds fine grained controls to controller callbacks.
star_disabled Dashboard Source Tickets Wiki Blog Network


Really Useful Social coding!

Codaset is an open system, so you can browse and search through all the open source projects, and check out what your friends are coding. Follow them, befriend them, and fork their code; quickly and easily.
Every single open source project you create is free, so come on and use Codaset at no cost. Your first private or semi-private project is also free. Read more about what it costs after that.

Git clone URL's...

Public: git://codaset.com/joelmoss/cakephp-callbacks.git
Active tickets:
0
Milestones:
0
Bookmarks:
10
Forks:
0


Callback Component

This component extends the CakePHP callbacks architecture, by supporting
callbacks in class properties.

Simply define any of the three callbacks defined in CallbackComponent::__callbacks
like this:

  class MyController extends AppController {
      var $beforeFilter = array('myCallback');
      function _myCallback() {
          # do something here
      }
  }

You can declare as many callbacks as you wish:

  class MyController extends AppController {
      var $beforeFilter = array('myCallback', 'anotherCallback', 'andAnotherOne');

Callbacks also support a number of options, which are passed to the callback:

  'only' An array of controller actions that this callback should be called on.
  'except' An array of controller actions that the callback will NOT be called on.
  'if' a method name, which returns true|false. Callback will only be run if method is true.
  'unless' a method name, which returns true|false. Callback will not be run if method is true.

  Example:

  class MyController extends AppController {
      var $beforeFilter = array(
          'myCallback' => array(
              'only' => array('index', 'view'),
              'if' => 'ifMethod'
          )
      );