MediaWiki
REL1_35
AbstractRestriction.php
Go to the documentation of this file.
1
<?php
23
namespace
MediaWiki\Block\Restriction
;
24
25
abstract
class
AbstractRestriction
implements
Restriction
{
26
31
public
const
TYPE
=
''
;
32
37
public
const
TYPE_ID
= 0;
38
42
protected
$blockId
;
43
47
protected
$value
;
48
56
public
function
__construct
(
$blockId
,
$value
) {
57
$this->blockId = (int)
$blockId
;
58
$this->value = (int)
$value
;
59
}
60
64
public
static
function
getType
() {
65
return
static::TYPE;
66
}
67
71
public
static
function
getTypeId
() {
72
return
static::TYPE_ID;
73
}
74
78
public
function
getBlockId
() {
79
return
$this->blockId
;
80
}
81
85
public
function
setBlockId
(
$blockId
) {
86
$this->blockId = (int)
$blockId
;
87
88
return
$this;
89
}
90
94
public
function
getValue
() {
95
return
$this->value
;
96
}
97
101
public
static
function
newFromRow
( \stdClass $row ) {
102
// @phan-suppress-next-line PhanTypeInstantiateAbstractStatic
103
return
new
static
( $row->ir_ipb_id, $row->ir_value );
104
}
105
109
public
function
toRow
() {
110
return
[
111
'ir_ipb_id'
=> $this->
getBlockId
(),
112
'ir_type'
=> $this->
getTypeId
(),
113
'ir_value'
=> $this->
getValue
(),
114
];
115
}
116
120
public
function
equals
(
Restriction
$other ) {
121
return
$this->
getHash
() === $other->
getHash
();
122
}
123
127
public
function
getHash
() {
128
return
$this->
getType
() .
'-'
. $this->
getValue
();
129
}
130
}
MediaWiki\Block\Restriction\AbstractRestriction
Definition
AbstractRestriction.php:25
MediaWiki\Block\Restriction\AbstractRestriction\setBlockId
setBlockId( $blockId)
Sets the id of the block.1.33 self
Definition
AbstractRestriction.php:85
MediaWiki\Block\Restriction\AbstractRestriction\TYPE_ID
const TYPE_ID
Numeric type identifier.
Definition
AbstractRestriction.php:37
MediaWiki\Block\Restriction\AbstractRestriction\$value
int $value
Definition
AbstractRestriction.php:47
MediaWiki\Block\Restriction\AbstractRestriction\getBlockId
getBlockId()
Gets the id of the block.1.33 int
Definition
AbstractRestriction.php:78
MediaWiki\Block\Restriction\AbstractRestriction\$blockId
int $blockId
Definition
AbstractRestriction.php:42
MediaWiki\Block\Restriction\AbstractRestriction\toRow
toRow()
Convert a restriction object into a row array for insertion.1.33 array
Definition
AbstractRestriction.php:109
MediaWiki\Block\Restriction\AbstractRestriction\newFromRow
static newFromRow(\stdClass $row)
Creates a new Restriction from a database row.1.33 static
Definition
AbstractRestriction.php:101
MediaWiki\Block\Restriction\AbstractRestriction\getValue
getValue()
Gets the value of the restriction.1.33 int
Definition
AbstractRestriction.php:94
MediaWiki\Block\Restriction\AbstractRestriction\getType
static getType()
Gets the type of restriction.1.33 string
Definition
AbstractRestriction.php:64
MediaWiki\Block\Restriction\AbstractRestriction\TYPE
const TYPE
String constant identifying the type of restriction.
Definition
AbstractRestriction.php:31
MediaWiki\Block\Restriction\AbstractRestriction\__construct
__construct( $blockId, $value)
Create Restriction.
Definition
AbstractRestriction.php:56
MediaWiki\Block\Restriction\AbstractRestriction\getHash
getHash()
Create a unique hash of the block restriction based on the type and value.1.33 string
Definition
AbstractRestriction.php:127
MediaWiki\Block\Restriction\AbstractRestriction\equals
equals(Restriction $other)
Determine if a restriction equals another restriction.1.33 bool
Definition
AbstractRestriction.php:120
MediaWiki\Block\Restriction\AbstractRestriction\getTypeId
static getTypeId()
Gets the id of the type of restriction.This id is used in the database.1.33 int
Definition
AbstractRestriction.php:71
MediaWiki\Block\Restriction\Restriction
Definition
Restriction.php:25
MediaWiki\Block\Restriction\Restriction\getHash
getHash()
Create a unique hash of the block restriction based on the type and value.
MediaWiki\Block\Restriction
Definition
AbstractRestriction.php:23
includes
block
Restriction
AbstractRestriction.php
Generated on Sat Apr 6 2024 00:06:57 for MediaWiki by
1.9.8