88 if ( $priority < self::MIN_PRIORITY || $priority > self::MAX_PRIORITY ) {
89 throw new \InvalidArgumentException(
'Invalid priority' );
92 if ( isset( $data[
'copyFrom'] ) ) {
93 $from = $data[
'copyFrom'];
95 throw new \InvalidArgumentException(
'Invalid copyFrom' );
98 'provider' =>
$from->provider,
100 'userInfo' =>
$from->userInfo,
101 'persisted' =>
$from->persisted,
102 'remembered' =>
$from->remembered,
103 'forceHTTPS' =>
$from->forceHTTPS,
104 'metadata' =>
$from->providerMetadata,
105 'idIsSafe' =>
$from->idIsSafe,
106 'forceUse' =>
$from->forceUse,
115 'persisted' =>
false,
116 'remembered' =>
true,
117 'forceHTTPS' =>
false,
127 throw new \InvalidArgumentException(
'Invalid session ID' );
130 if ( $data[
'userInfo'] !== null && !$data[
'userInfo'] instanceof
UserInfo ) {
131 throw new \InvalidArgumentException(
'Invalid userInfo' );
134 if ( !$data[
'provider'] && $data[
'id'] === null ) {
135 throw new \InvalidArgumentException(
136 'Must supply an ID when no provider is given'
140 if ( $data[
'metadata'] !== null && !is_array( $data[
'metadata'] ) ) {
141 throw new \InvalidArgumentException(
'Invalid metadata' );
144 $this->provider = $data[
'provider'];
145 if ( $data[
'id'] !== null ) {
146 $this->
id = $data[
'id'];
147 $this->idIsSafe = $data[
'idIsSafe'];
150 $this->
id = $this->provider->
getManager()->generateSessionId();
151 $this->idIsSafe =
true;
155 $this->userInfo = $data[
'userInfo'];
156 $this->persisted = (bool)$data[
'persisted'];
157 if ( $data[
'provider'] !== null ) {
158 if ( $this->userInfo !== null && !$this->userInfo->isAnon() && $this->userInfo->isVerified() ) {
159 $this->remembered = (bool)$data[
'remembered'];
161 $this->providerMetadata = $data[
'metadata'];
163 $this->
forceHTTPS = (bool)$data[
'forceHTTPS'];
275 ( $this->userInfo ?:
'<null>' ) . $this->
getId();
285 return $a->getPriority() - $b->getPriority();
the array() calling protocol came about after MediaWiki 1.4rc1.
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