标签云

微信群

扫码加入我们

WeChat QR Code


Note that for PHP >= 5.0 you can implement this using the Observer / Subject interfaces defined in the SPL: php.net/manual/en/class.splobserver.php

2018年12月11日11分52秒

Pedantic note: this is not an example of the Observer pattern. It's an example of the Mediator Pattern. True observers are purely notification, there is no message passing or conditional notification (nor is there a central manager for controlling notifications). It doesn't make the answer wrong, but it should be noted to stop people calling things by the wrong name...

2018年12月11日11分52秒

Note that when using multiple hooks/listeners, you should only return either strings or arrays, not both. I have implemented something similar for Hound CMS - getbutterfly.com/hound.

2018年12月11日11分52秒

Isn't this a decorator?

2018年12月10日11分52秒

I read up on Wikipedia about this and, whoa, you're right! :)

2018年12月11日11分52秒

I'd add DokuWiki to the list of systems you may have a look at. It has a nice event system that allows for a rich plugin ecosystem.

1970年01月01日00分03秒

This is more of a "push API" than a "plugin" system - you're providing a way for other services to receive notification of selected events. What is generally meant by "plugins" is that you can install the application and then add functionality to customise its behaviour to your purposes, which requires the plugin to be running locally - or at least have a secure and efficient 2-way communication to provide information to the application not just take it from it. The two features are somewhat distinct, and for many cases a "feed" (e.g. RSS, iCal) is a simple alternative to a push API.

2018年12月11日11分52秒