Skip to content
This repository has been archived by the owner on Jul 20, 2020. It is now read-only.

Implements Observers #15

Open
WanWizard opened this issue Jul 23, 2012 · 3 comments
Open

Implements Observers #15

WanWizard opened this issue Jul 23, 2012 · 3 comments

Comments

@WanWizard
Copy link
Owner

Observers allow for custom callbacks to be defined at critical locations in the DataMapper core, which could be used to pre- or post process the object's data, add additional logic, etc.

Original issue from DataMapper v1.

see http://codeigniter.com/forums/viewthread/149388/P530/#783616 and http://codeigniter.com/forums/viewthread/149388/P540/#783667

@WanWizard
Copy link
Owner Author

Observers should replace the static code now built-in for working with created and updated timestamps in records. This means less code and quicker execution for those that don't need this feature.

@WanWizard
Copy link
Owner Author

Reply from @colonelchorine

Wan, I noticed that Jamierumbelow's base model MY_Model uses various callbacks/hooks for before and after events. I've always found this kind of confusing, because I find that by simply using standard OOP inheritance, you can accomplish the same thing.

Like so:

class Something extends BaseModel {
   function update() {
      do_something_before();
      parent::update();
      do_something_after();
   }
}

Not sure if this fits into the Datamapper pattern you've made, but it was just a thought.

@WanWizard
Copy link
Owner Author

This works for real "before" and "after", but not for hook points in the code, like "before_save", "before_insert", etc.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant