58 parent::__construct(
$type, $key );
59 foreach ( [
'doWork',
'doCachedWork',
'fallback',
'error' ] as $name ) {
60 if ( isset( $callbacks[$name] ) ) {
61 if ( !is_callable( $callbacks[$name] ) ) {
62 throw new MWException(
"Invalid callback provided for '$name' function." );
64 $this->$name = $callbacks[$name];
67 if ( !isset( $this->
doWork ) ) {
68 throw new MWException(
"No callback provided for 'doWork' function." );
70 $this->cacheable = isset( $this->doCachedWork );
74 return ( $this->
doWork )();
78 if ( $this->doCachedWork ) {
79 return ( $this->doCachedWork )();
91 public function error( $status ) {
93 return ( $this->
error )( $status );