MediaWiki REL1_34
PageRestriction.php
Go to the documentation of this file.
1<?php
24
26
30 const TYPE = 'page';
31
35 const TYPE_ID = 1;
36
40 protected $title;
41
45 public function matches( \Title $title ) {
46 if ( !$this->getTitle() ) {
47 return false;
48 }
49
50 return $title->equals( $this->getTitle() );
51 }
52
60 public function setTitle( \Title $title ) {
61 $this->title = $title;
62
63 return $this;
64 }
65
72 public function getTitle() {
73 if ( $this->title === null ) {
74 $this->title = \Title::newFromID( $this->value );
75
76 // If the title does not exist, set to false to prevent multiple database
77 // queries.
78 if ( $this->title === null ) {
79 $this->title = false;
80 }
81 }
82
83 return $this->title ?? null;
84 }
85
89 public static function newFromRow( \stdClass $row ) {
91 $restriction = parent::newFromRow( $row );
92 '@phan-var self $restriction';
93
94 // If the page_namespace and the page_title were provided, add the title to
95 // the restriction.
96 if ( isset( $row->page_namespace ) && isset( $row->page_title ) ) {
97 // Clone the row so it is not mutated.
98 $row = clone $row;
99 $row->page_id = $row->ir_value;
100 $title = \Title::newFromRow( $row );
101 $restriction->setTitle( $title );
102 }
103
104 return $restriction;
105 }
106}
matches(\Title $title)
Determine if a restriction matches a given title.1.33 bool
static newFromRow(\stdClass $row)
Creates a new Restriction from a database row.1.33 static
Represents a title within MediaWiki.
Definition Title.php:42
equals(LinkTarget $title)
Compare with another title.
Definition Title.php:4113