23use InvalidArgumentException;
46 throw new InvalidArgumentException(
'Database must be null or a non-empty string.' );
50 throw new InvalidArgumentException(
'Schema must be null or a non-empty string.' );
52 throw new InvalidArgumentException(
'Schema must be null if database is null.' );
56 throw new InvalidArgumentException(
"Prefix must be a string." );
66 if ( $domain instanceof
self ) {
70 $parts = array_map( [ __CLASS__,
'decode' ], explode(
'-', $domain ) );
75 if ( count( $parts ) == 1 ) {
77 } elseif ( count( $parts ) == 2 ) {
79 } elseif ( count( $parts ) == 3 ) {
82 throw new InvalidArgumentException(
"Domain '$domain' has too few or too many parts." );
100 return new self(
null,
null,
'' );
108 if ( $other instanceof
self ) {
110 $this->database === $other->database &&
111 $this->schema === $other->schema &&
112 $this->prefix === $other->prefix
116 return ( $this->
getId() === $other );
141 ( $this->database === $other->database || $this->database ===
null ) &&
142 ( $this->schema === $other->schema || $this->schema ===
null ) &&
143 $this->prefix === $other->prefix
153 $this->database ===
null && $this->schema ===
null && $this->prefix ===
''
182 if ( $this->equivalentString ===
null ) {
193 $parts = [ (
string)$this->database ];
194 if ( $this->schema !==
null ) {
197 if ( $this->prefix !=
'' || $this->schema !==
null ) {
206 return implode(
'-', array_map( [ __CLASS__,
'encode' ], $parts ) );
209 private static function encode( $decoded ) {
212 $length = strlen( $decoded );
213 for ( $i = 0; $i < $length; ++$i ) {
214 $char = $decoded[$i];
215 if ( $char ===
'-' ) {
217 } elseif ( $char ===
'?' ) {
227 private static function decode( $encoded ) {
230 $length = strlen( $encoded );
231 for ( $i = 0; $i < $length; ++$i ) {
232 $char = $encoded[$i];
233 if ( $char ===
'?' ) {
234 $nextChar = $encoded[$i + 1] ??
null;
235 if ( $nextChar ===
'h' ) {
238 } elseif ( $nextChar ===
'?' ) {
256 return $this->
getId();
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
Class to handle database/prefix specification for IDatabase domains.
string $equivalentString
Cache of convertToString()
isCompatible( $other)
Check whether the domain $other meets the specifications of this domain.
static newFromId( $domain)
__construct( $database, $schema, $prefix)
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible true was required This is the default since MediaWiki *some string
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