MediaWiki  REL1_31
TitleArrayFromResult.php
Go to the documentation of this file.
1 <?php
28 
29 class TitleArrayFromResult extends TitleArray implements Countable {
31  public $res;
32 
33  public $key;
34 
35  public $current;
36 
37  function __construct( $res ) {
38  $this->res = $res;
39  $this->key = 0;
40  $this->setCurrent( $this->res->current() );
41  }
42 
47  protected function setCurrent( $row ) {
48  if ( $row === false ) {
49  $this->current = false;
50  } else {
51  $this->current = Title::newFromRow( $row );
52  }
53  }
54 
58  public function count() {
59  return $this->res->numRows();
60  }
61 
62  function current() {
63  return $this->current;
64  }
65 
66  function key() {
67  return $this->key;
68  }
69 
70  function next() {
71  $row = $this->res->next();
72  $this->setCurrent( $row );
73  $this->key++;
74  }
75 
76  function rewind() {
77  $this->res->rewind();
78  $this->key = 0;
79  $this->setCurrent( $this->res->current() );
80  }
81 
85  function valid() {
86  return $this->current !== false;
87  }
88 }
use
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
Definition: APACHE-LICENSE-2.0.txt:10
TitleArrayFromResult\current
current()
Definition: TitleArrayFromResult.php:62
TitleArrayFromResult\setCurrent
setCurrent( $row)
Definition: TitleArrayFromResult.php:47
TitleArrayFromResult\$current
$current
Definition: TitleArrayFromResult.php:35
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:37
Wikimedia\Rdbms\IResultWrapper
Result wrapper for grabbing data queried from an IDatabase object.
Definition: IResultWrapper.php:24
Title\newFromRow
static newFromRow( $row)
Make a Title object from a DB row.
Definition: Title.php:464
TitleArrayFromResult
Definition: TitleArrayFromResult.php:29
TitleArrayFromResult\next
next()
Definition: TitleArrayFromResult.php:70
TitleArrayFromResult\count
count()
Definition: TitleArrayFromResult.php:58
TitleArrayFromResult\key
key()
Definition: TitleArrayFromResult.php:66
TitleArrayFromResult\__construct
__construct( $res)
Definition: TitleArrayFromResult.php:37
TitleArrayFromResult\rewind
rewind()
Definition: TitleArrayFromResult.php:76
TitleArrayFromResult\$key
$key
Definition: TitleArrayFromResult.php:33
TitleArrayFromResult\$res
IResultWrapper $res
Definition: TitleArrayFromResult.php:31
TitleArray
The TitleArray class only exists to provide the newFromResult method at pre- sent.
Definition: TitleArray.php:33
TitleArrayFromResult\valid
valid()
Definition: TitleArrayFromResult.php:85