Akelos Framework v1 forum archive. This forum is no longer maintained. To report bugs please visit https://github.com/akelos/akelos/issues
    • CommentAuthorsuthern

    Howdy! I'm back, working on a much smaller and more useful project this time. :)

    In the current project I would like to send a couple emails when an ActiveRecord is saved or destroyed.

    What is the cleanest way to do this? I could use observers, callbacks, or call the functions directly from the add/edit/destroy.

    Using Observers: Does someone have a complete example using these? Inside 'AkActiveRecord' it just says 'see Callbacks'. I know how to use callbacks inside of \models\MODELNAME.php, but do not know the first thing about observers or how to use them.

    Using Callbacks: This would work, but Ak::import_mailer('notifier') does not work inside a \models\MODELNAME.php file. It works fine in functions in controllers though. I'm not sure how to call 'notifier' while inside a model class.

    Using calls directly from functions inside the add/edit/destroy commands: This is a bad idea, as it clutters up the code and would only happen when records are saved using add/edit/remove functions. I have a few ajax calls that add/edit records, and the triggers should be fired when using them as well.

    What would you use? Thanks!

    • CommentAuthorsuthern

    For now I'll put the functions in the bottom of MODELNAME_controller.php and call them from ALL my save/edit/destroy functions (ajax and normal alike).

    But I'd still love to learn how to use observers. :)