Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * A class that allows multiple method inheritance by queuing different implementations,
- * and running them one after another. Works only for static classes, but it's not really mandatory.
- */
- abstract class Queueable
- {
- protected static $_implementations = array();
- protected function __construct() {}
- /*
- * Example: Entries::register_method('list', 'Entries_Sortable');
- */
- public static function register_method($method_name, $class_name)
- {
- if(!isset(static::$_implementations[$method_name]))
- {
- static::$_implementations[$method_name] = array();
- }
- static::$_implementations[$method_name][] = $class_name;
- }
- protected static function call($method_name, $arguments)
- {
- if(isset(static::$_implementations[$method_name]))
- {
- foreach(static::$_implementations[$method_name] as $class)
- {
- call_user_func_array($class.'::'.$method_name, $arguments);
- }
- }
- }
- public static function __callStatic($name, $arguments)
- {
- return static::call($name, $arguments);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement