MediaWiki
1.33.0
|
A registry service for SlotRoleHandlers, used to define which slot roles are available on which page. More...
Public Member Functions | |
__construct (NameTableStore $roleNamesStore) | |
defineRole ( $role, callable $instantiator) | |
Defines a slot role. More... | |
defineRoleWithModel ( $role, $model, $layout=[]) | |
Defines a slot role that allows only the given content model, and has no special behavior. More... | |
getAllowedRoles (LinkTarget $title) | |
Returns the list of roles allowed when creating a new revision on the given page. More... | |
getDefinedRoles () | |
Returns the list of roles defined by calling defineRole(). More... | |
getKnownRoles () | |
Returns the list of known roles, including the ones returned by getDefinedRoles(), and roles that exist according to the NameTableStore provided to the constructor. More... | |
getRequiredRoles (LinkTarget $title) | |
Returns the list of roles required when creating a new revision on the given page. More... | |
getRoleHandler ( $role) | |
Gets the SlotRoleHandler that should be used when processing content of the given role. More... | |
isDefinedRole ( $role) | |
Whether the given role is defined, that is, it was defined by calling defineRole(). More... | |
isKnownRole ( $role) | |
Whether the given role is known, that is, it's either defined or exist according to the NameTableStore provided to the constructor. More... | |
Private Attributes | |
SlotRoleHandler[] | $handlers |
callable[] | $instantiators = [] |
NameTableStore | $roleNamesStore |
A registry service for SlotRoleHandlers, used to define which slot roles are available on which page.
Extensions may use the SlotRoleRegistry to register the slots they define.
In the context of the SlotRoleRegistry, it is useful to distinguish between "defined" and "known" slot roles: A slot role is "defined" if defineRole() or defineRoleWithModel() was called for that role. A slot role is "known" if the NameTableStore provided to the constructor as the $roleNamesStore parameter has an ID associated with that role, which essentially means that the role at some point has been used on the wiki. Roles that are not "defined" but are "known" typically belong to extensions that used to be installed on the wiki, but no longer are. Such slots should be considered ok for display and administrative operations, but only "defined" slots should be supported for editing.
Definition at line 48 of file SlotRoleRegistry.php.
Revision\SlotRoleRegistry::__construct | ( | NameTableStore | $roleNamesStore | ) |
NameTableStore | $roleNamesStore |
Definition at line 68 of file SlotRoleRegistry.php.
References Revision\SlotRoleRegistry\$roleNamesStore.
Revision\SlotRoleRegistry::defineRole | ( | $role, | |
callable | $instantiator | ||
) |
Defines a slot role.
For use by extensions that wish to define roles beyond the main slot role.
string | $role | The role name of the slot to define. This should follow the same convention as message keys: |
callable | $instantiator | called with $role as a parameter; Signature: function ( string $role ): SlotRoleHandler |
Definition at line 84 of file SlotRoleRegistry.php.
References Revision\SlotRoleRegistry\isDefinedRole().
Referenced by Revision\SlotRoleRegistry\defineRoleWithModel().
Revision\SlotRoleRegistry::defineRoleWithModel | ( | $role, | |
$model, | |||
$layout = [] |
|||
) |
Defines a slot role that allows only the given content model, and has no special behavior.
For use by extensions that wish to define roles beyond the main slot role, but have no need to implement any special behavior for that slot.
string | $role | The role name of the slot to define, see defineRole() for more information. |
string | $model | A content model name, see ContentHandler |
array | $layout | See SlotRoleHandler getOutputLayoutHints |
Definition at line 106 of file SlotRoleRegistry.php.
References Revision\SlotRoleRegistry\defineRole(), and use.
Revision\SlotRoleRegistry::getAllowedRoles | ( | LinkTarget | $title | ) |
Returns the list of roles allowed when creating a new revision on the given page.
The choice should not depend on external state, such as the page content. Note that existing revisions of that page are not guaranteed to comply with this list.
All implementations of this method are required to return at least all "required" roles.
LinkTarget | $title |
Definition at line 163 of file SlotRoleRegistry.php.
References Revision\SlotRoleRegistry\getDefinedRoles().
Revision\SlotRoleRegistry::getDefinedRoles | ( | ) |
Returns the list of roles defined by calling defineRole().
This list should be used when enumerating slot roles that can be used for editing.
Definition at line 193 of file SlotRoleRegistry.php.
Referenced by Revision\SlotRoleRegistry\getAllowedRoles(), Revision\SlotRoleRegistry\getKnownRoles(), and Revision\SlotRoleRegistry\isDefinedRole().
Revision\SlotRoleRegistry::getKnownRoles | ( | ) |
Returns the list of known roles, including the ones returned by getDefinedRoles(), and roles that exist according to the NameTableStore provided to the constructor.
This list should be used when enumerating slot roles that can be used in queries or for display.
Definition at line 206 of file SlotRoleRegistry.php.
References Revision\SlotRoleRegistry\getDefinedRoles().
Referenced by Revision\SlotRoleRegistry\isKnownRole().
Revision\SlotRoleRegistry::getRequiredRoles | ( | LinkTarget | $title | ) |
Returns the list of roles required when creating a new revision on the given page.
The should not depend on external state, such as the page content. Note that existing revisions of that page are not guaranteed to comply with this list.
All required roles are implicitly considered "allowed", so any roles returned by this method will also be returned by getAllowedRoles().
LinkTarget | $title |
Definition at line 181 of file SlotRoleRegistry.php.
Revision\SlotRoleRegistry::getRoleHandler | ( | $role | ) |
Gets the SlotRoleHandler that should be used when processing content of the given role.
string | $role |
InvalidArgumentException | If $role is not a known slot role. |
Definition at line 124 of file SlotRoleRegistry.php.
References $handler, Revision\SlotRoleRegistry\isDefinedRole(), Revision\SlotRoleRegistry\isKnownRole(), and wfWarn().
Revision\SlotRoleRegistry::isDefinedRole | ( | $role | ) |
Whether the given role is defined, that is, it was defined by calling defineRole().
string | $role |
Definition at line 219 of file SlotRoleRegistry.php.
References Revision\SlotRoleRegistry\getDefinedRoles().
Referenced by Revision\SlotRoleRegistry\defineRole(), and Revision\SlotRoleRegistry\getRoleHandler().
Revision\SlotRoleRegistry::isKnownRole | ( | $role | ) |
Whether the given role is known, that is, it's either defined or exist according to the NameTableStore provided to the constructor.
string | $role |
Definition at line 230 of file SlotRoleRegistry.php.
References Revision\SlotRoleRegistry\getKnownRoles().
Referenced by Revision\SlotRoleRegistry\getRoleHandler().
|
private |
Definition at line 63 of file SlotRoleRegistry.php.
|
private |
Definition at line 58 of file SlotRoleRegistry.php.
|
private |
Definition at line 53 of file SlotRoleRegistry.php.
Referenced by Revision\SlotRoleRegistry\__construct().