Go to the documentation of this file.
26 use InvalidArgumentException;
28 use OutOfBoundsException;
29 use Wikimedia\Assert\Assert;
76 $row = clone $slot->row;
79 foreach ( $overrides
as $key =>
$value ) {
106 'slot_revision_id' =>
null,
125 Assert::parameterType(
'string', $role,
'$role' );
129 'slot_revision_id' =>
null,
130 'slot_origin' =>
null,
131 'content_size' =>
null,
132 'content_sha1' =>
null,
133 'slot_content_id' =>
null,
134 'content_address' =>
null,
135 'role_name' => $role,
165 Assert::parameterType(
'integer', $revisionId,
'$revisionId' );
166 Assert::parameterType(
'integer', $contentId,
'$contentId' );
167 Assert::parameterType(
'string', $contentAddress,
'$contentAddress' );
170 throw new LogicException(
171 "Mismatching revision ID $revisionId: "
172 .
"The slot already belongs to revision {$protoSlot->getRevision()}. "
173 .
"Use SlotRecord::newInherited() to re-use content between revisions."
178 throw new LogicException(
179 "Mismatching blob address $contentAddress: "
180 .
"The slot already has content at {$protoSlot->getAddress()}."
185 throw new LogicException(
186 "Mismatching content ID $contentId: "
187 .
"The slot already has content row {$protoSlot->getContentId()} associated."
193 throw new InvalidArgumentException(
194 "An inherited blob should have a content address!"
197 if ( !$protoSlot->
hasField(
'slot_origin' ) ) {
198 throw new InvalidArgumentException(
199 "A saved inherited slot should have an origin set!"
204 $origin = $revisionId;
208 'slot_revision_id' => $revisionId,
209 'slot_content_id' => $contentId,
210 'slot_origin' => $origin,
211 'content_address' => $contentAddress,
231 Assert::parameterType(
'object',
$row,
'$row' );
232 Assert::parameterType(
'Content|callable',
$content,
'$content' );
235 property_exists(
$row,
'slot_id' ),
240 property_exists(
$row,
'slot_revision_id' ),
241 '$row->slot_revision_id',
245 property_exists(
$row,
'slot_content_id' ),
246 '$row->slot_content_id',
250 property_exists(
$row,
'content_address' ),
251 '$row->content_address',
255 property_exists(
$row,
'model_name' ),
260 property_exists(
$row,
'slot_origin' ),
265 !property_exists(
$row,
'slot_inherited' ),
266 '$row->slot_inherited',
270 !property_exists(
$row,
'slot_revision' ),
271 '$row->slot_revision',
285 throw new LogicException( __CLASS__ .
' is not serializable.' );
308 $obj = call_user_func( $this->
content, $this );
310 Assert::postcondition(
312 'Slot content callback should return a Content object'
331 if ( !isset( $this->row->$name ) ) {
333 if ( property_exists( $this->row,
$name ) ) {
336 throw new OutOfBoundsException(
'No such field: ' .
$name );
340 $value = $this->row->$name;
382 return isset( $this->row->$name );
430 return $this->
hasField(
'content_address' );
441 return $this->
hasField(
'slot_revision_id' );
484 $this->
setField(
'content_size', $size );
499 $format = $this->
hasField(
'format_name' )
503 $data = $this->
getContent()->serialize( $format );
505 $this->
setField(
'content_sha1', $sha1 );
523 $this->
setField(
'model_name', $model );
541 if ( $this->
hasField(
'format_name' ) ) {
553 $this->row->$name =
$value;
565 return \Wikimedia\base_convert( sha1(
$blob ), 16, 36, 31 );
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
per default it will return the text for text based content
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
Base interface for content objects.
Allows to change the fields on the form that will be generated $name
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
getModel()
Returns the ID of the content model used by this Content object.