MediaWiki master
ModuleMode.php
Go to the documentation of this file.
1<?php
2
4
15enum ModuleMode: string {
16 case DISABLED = 'disabled'; // treated as if the module does not exist
17 case HIDDEN = 'hidden'; // callable, excluded from /discovery and the REST Sandbox
18 case DISCOVERABLE = 'discoverable'; // callable, listed in /discovery, excluded from the REST Sandbox
19 case PUBLISHED = 'published'; // callable, listed in /discovery and the REST Sandbox
20
28 public static function getModuleMode( ?AudienceDesignation $ad ): ModuleMode {
29 if ( $ad === null ) {
30 return self::DISABLED;
31 }
32
33 return match ( $ad ) {
34 AudienceDesignation::PUBLIC => self::PUBLISHED,
35 AudienceDesignation::INTERNAL => self::PUBLISHED,
36 AudienceDesignation::BETA => self::PUBLISHED
37 };
38 }
39
47 public static function getModeParams( ?AudienceDesignation $ad ): array {
48 $params = [];
49
50 if ( $ad === AudienceDesignation::BETA ) {
51 $params['group'] = 'beta';
52 }
53 if ( $ad === AudienceDesignation::INTERNAL ) {
54 $params['group'] = 'internal';
55 }
56
57 return $params;
58 }
AudienceDesignation
Describes the set of audience designations available to REST modules.
ModuleMode
Describes the set of functionality applied to a module by the REST API framework.
@ getModuleMode
Gets the module mode for a given audience designation.