MediaWiki  1.30.0
GadgetDefinitionContentHandler.php
Go to the documentation of this file.
1 <?php
24  public function __construct() {
25  parent::__construct( 'GadgetDefinition' );
26  }
27 
32  public function canBeUsedOn( Title $title ) {
33  return $title->inNamespace( NS_GADGET_DEFINITION );
34  }
35 
36  protected function getContentClass() {
37  return 'GadgetDefinitionContent';
38  }
39 
40  public function makeEmptyContent() {
41  $class = $this->getContentClass();
42  return new $class( FormatJson::encode( $this->getDefaultMetadata(), "\t" ) );
43  }
44 
45  public function getDefaultMetadata() {
46  return [
47  'settings' => [
48  'rights' => [],
49  'default' => false,
50  'hidden' => false,
51  'skins' => [],
52  'category' => ''
53  ],
54  'module' => [
55  'scripts' => [],
56  'styles' => [],
57  'peers' => [],
58  'dependencies' => [],
59  'messages' => [],
60  'type' => '',
61  ],
62  ];
63  }
64 }
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
FormatJson\encode
static encode( $value, $pretty=false, $escaping=0)
Returns the JSON representation of a value.
Definition: FormatJson.php:127
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:932
GadgetDefinitionContentHandler\getContentClass
getContentClass()
Definition: GadgetDefinitionContentHandler.php:36
GadgetDefinitionContentHandler\canBeUsedOn
canBeUsedOn(Title $title)
Definition: GadgetDefinitionContentHandler.php:32
GadgetDefinitionContentHandler
Definition: GadgetDefinitionContentHandler.php:23
GadgetDefinitionContentHandler\makeEmptyContent
makeEmptyContent()
Creates an empty TextContent object.
Definition: GadgetDefinitionContentHandler.php:40
Title
Represents a title within MediaWiki.
Definition: Title.php:39
GadgetDefinitionContentHandler\getDefaultMetadata
getDefaultMetadata()
Definition: GadgetDefinitionContentHandler.php:45
JsonContentHandler
Content handler for JSON.
Definition: JsonContentHandler.php:30
GadgetDefinitionContentHandler\__construct
__construct()
Definition: GadgetDefinitionContentHandler.php:24