It looks like a template method pattern, but the methods in question are not abstract and the child class is not being forced to implement them. I'd say it's just a common use of inheritance or maybe a borderline template method pattern.
I'd rather implement such things via events/delegates/callbacks, though. It is much clearer then what you can hook up to and you can't accidentally override necessary behaviour. It's also more flexible.
@GSto
Here's an example of using callbacks with PHP. It's not as elegant as in other languages with native event support (like C# offers for example), but it's flexible and you can register such callbacks in the constructor of a child class for example. This website here told me how to implement callbacks in PHP, the heart of it is the call_user_func function of PHP. This can register as many handlers as you like and anything with a reference to the object can register handlers.
class Model {
protected $_before_create_callbacks = array();
protected $_after_create_callbacks = array();
function register_before_create_handler($callback) {
$this->_before_create_callbacks[] = $callback;
}
function register_after_create_handler($callback) {
$this->_after_create_callbacks[] = $callback;
}
function create(){
$this->before_create();
//logic of create...
$this->after_create();
}
protected function before_create() {
foreach ($this->_before_create_callbacks as $callback){
call_user_func($callback);
}
}
protected function before_create() {
foreach ($this->$_after_create_callbacks as $callback){
call_user_func($callback);
}
}
}
function someFunction(){
logSomething();
}
$anyModel->register_before_create_handler("someFunction");