diff options
Diffstat (limited to 'includes/CallableUpdate.php')
-rw-r--r-- | includes/CallableUpdate.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/includes/CallableUpdate.php b/includes/CallableUpdate.php new file mode 100644 index 00000000..6eb55413 --- /dev/null +++ b/includes/CallableUpdate.php @@ -0,0 +1,30 @@ +<?php + +/** + * Deferrable Update for closure/callback + */ +class MWCallableUpdate implements DeferrableUpdate { + + /** + * @var closure/callabck + */ + private $callback; + + /** + * @param callable $callback + */ + public function __construct( $callback ) { + if ( !is_callable( $callback ) ) { + throw new MWException( 'Not a valid callback/closure!' ); + } + $this->callback = $callback; + } + + /** + * Run the update + */ + public function doUpdate() { + call_user_func( $this->callback ); + } + +} |