Best / Official Name for _beforeFoo Callback Design Template

Many PHP systems will implement object types (for example, Models) that allow the client programmer to define a method in their classes like this:

class Car extends Model { public function _afterSave() { //do something every-time this model is saved } } 

In documentation and textbooks, this pattern is usually introduced as an observer / listener pattern.

However, although you can describe this method as listening to actions on the parent class, it looks like something other than the classic OOP observer pattern .

Is there a formal name for a template that allows client programmers to define these types of methods before / after, or is it just something early PHP developers outlined before the language developed its java / C #, for example, OOP?

+4
source share
1 answer

Assuming that these methods are called using a model or some other part of the framework (I don’t know PHP), this is a template template template, and the methods that serve as extension points are often called hooks.

+5
source

Source: https://habr.com/ru/post/1403549/


All Articles