** editmyoptions controls whether a user may change their preferences.
* Add new hook AbortTalkPageEmailNotification, this will be used to determine
whether to send the regular talk page email notification
+* Action classes registered in $wgActions are now also supported in the form of
+ a callback (which returns an instance of Action) instead of providing the name
+ of a subclass of Action.
* (bug 46513) Vector: Add the collapsibleTabs script from the Vector extension.
* Added $wgRecentChangesFlags for defining new flags for RecentChanges and
watchlists.
* the action is disabled, or null if it's not recognised
* @param $action String
* @param $overrides Array
- * @return bool|null|string
+ * @return bool|null|string|callable
*/
final private static function getClass( $action, array $overrides ) {
global $wgActions;
* if it is not recognised
*/
final public static function factory( $action, Page $page, IContextSource $context = null ) {
- $class = self::getClass( $action, $page->getActionOverrides() );
- if ( $class ) {
- $obj = new $class( $page, $context );
+ $classOrCallable = self::getClass( $action, $page->getActionOverrides() );
+
+ if ( is_string( $classOrCallable ) ) {
+ $obj = new $classOrCallable( $page, $context );
return $obj;
}
- return $class;
+
+ if ( is_callable( $classOrCallable ) ) {
+ return call_user_func_array( $classOrCallable, array( $page, $context ) );
+ }
+
+ return $classOrCallable;
}
/**
}
/**
- * Protected constructor: use Action::factory( $action, $page ) to actually build
- * these things in the real world
+ * Constructor.
+ *
+ * Only public since 1.21
+ *
* @param $page Page
* @param $context IContextSource
*/
- protected function __construct( Page $page, IContextSource $context = null ) {
+ public function __construct( Page $page, IContextSource $context = null ) {
$this->page = $page;
$this->context = $context;
}