MediaWiki  master
SlotRoleHandler.php
Go to the documentation of this file.
1 <?php
23 namespace MediaWiki\Revision;
24 
27 
38 
42  private $role;
43 
48  private $layout = [
49  'display' => 'section', // use 'none' to suppress
50  'region' => 'center',
51  'placement' => 'append'
52  ];
53 
57  private $derived;
58 
62  private $contentModel;
63 
80  public function __construct( $role, $contentModel, $layout = [], bool $derived = false ) {
81  $this->role = $role;
82  $this->contentModel = $contentModel;
83  $this->layout = array_merge( $this->layout, $layout );
84  $this->derived = $derived;
85  }
86 
90  public function getRole() {
91  return $this->role;
92  }
93 
115  public function getOutputLayoutHints() {
116  return $this->layout;
117  }
118 
123  public function isDerived(): bool {
124  return $this->derived;
125  }
126 
133  public function getNameMessageKey() {
134  return 'slot-name-' . $this->role;
135  }
136 
150  public function getDefaultModel( $page ) {
151  return $this->contentModel;
152  }
153 
171  public function isAllowedModel( $model, PageIdentity $page ) {
172  return ( $model === $this->contentModel );
173  }
174 
188  public function supportsArticleCount() {
189  return false;
190  }
191 
192 }
Page\PageIdentity
Interface for objects (potentially) representing an editable wiki page.
Definition: PageIdentity.php:64
MediaWiki\Revision\SlotRoleHandler\getNameMessageKey
getNameMessageKey()
The message key for the translation of the slot name.
Definition: SlotRoleHandler.php:133
MediaWiki\Revision\SlotRoleHandler\__construct
__construct( $role, $contentModel, $layout=[], bool $derived=false)
Definition: SlotRoleHandler.php:80
MediaWiki\Revision\SlotRoleHandler\getOutputLayoutHints
getOutputLayoutHints()
Layout hints for use while laying out the combined output of all slots, typically by RevisionRenderer...
Definition: SlotRoleHandler.php:115
MediaWiki\Revision\SlotRoleHandler\getRole
getRole()
Definition: SlotRoleHandler.php:90
MediaWiki\Revision\SlotRoleHandler
SlotRoleHandler instances are used to declare the existence and behavior of slot roles.
Definition: SlotRoleHandler.php:37
MediaWiki\Revision
Definition: ArchivedRevisionLookup.php:21
MediaWiki\Revision\SlotRoleHandler\$role
string $role
Definition: SlotRoleHandler.php:42
MediaWiki\Revision\SlotRoleHandler\isAllowedModel
isAllowedModel( $model, PageIdentity $page)
Determines whether the given model can be used on this slot on the given page.
Definition: SlotRoleHandler.php:171
MediaWiki\Revision\SlotRoleHandler\$derived
bool $derived
Definition: SlotRoleHandler.php:57
MediaWiki\Revision\SlotRoleHandler\supportsArticleCount
supportsArticleCount()
Whether this slot should be considered when determining whether a page should be counted as an "artic...
Definition: SlotRoleHandler.php:188
MediaWiki\Revision\SlotRoleHandler\$contentModel
string $contentModel
Definition: SlotRoleHandler.php:62
MediaWiki\Linker\LinkTarget
Definition: LinkTarget.php:26
MediaWiki\Revision\SlotRoleHandler\isDerived
isDerived()
Definition: SlotRoleHandler.php:123
MediaWiki\Revision\SlotRoleHandler\$layout
string[] $layout
Definition: SlotRoleHandler.php:48
MediaWiki\Revision\SlotRoleHandler\getDefaultModel
getDefaultModel( $page)
Determines the content model to use per default for this slot on the given page.
Definition: SlotRoleHandler.php:150