MediaWiki
master
AbstractRestriction.php
Go to the documentation of this file.
1
<?php
9
namespace
MediaWiki\Block\Restriction
;
10
11
abstract
class
AbstractRestriction
implements
Restriction
{
12
17
public
const
TYPE
=
''
;
18
23
public
const
TYPE_ID
= 0;
24
28
protected
$blockId
;
29
33
protected
$value
;
34
42
public
function
__construct
(
$blockId
,
$value
) {
43
$this->blockId = (int)
$blockId
;
44
$this->value = (int)
$value
;
45
}
46
50
public
static
function
getType
() {
51
return
static::TYPE;
52
}
53
57
public
static
function
getTypeId
() {
58
return
static::TYPE_ID;
59
}
60
64
public
function
getBlockId
() {
65
return
$this->blockId
;
66
}
67
71
public
function
setBlockId
(
$blockId
) {
72
$this->blockId = (int)
$blockId
;
73
74
return
$this;
75
}
76
80
public
function
getValue
() {
81
return
$this->value
;
82
}
83
87
public
static
function
newFromRow
( \stdClass $row ) {
88
// @phan-suppress-next-line PhanTypeInstantiateAbstractStatic
89
return
new
static
( $row->ir_ipb_id, $row->ir_value );
90
}
91
95
public
function
toRow
() {
96
return
[
97
'ir_ipb_id'
=> $this->
getBlockId
(),
98
'ir_type'
=> $this->
getTypeId
(),
99
'ir_value'
=> $this->
getValue
(),
100
];
101
}
102
106
public
function
equals
(
Restriction
$other ) {
107
return
$this->
getHash
() === $other->
getHash
();
108
}
109
113
public
function
getHash
() {
114
return
$this->
getType
() .
'-'
. $this->
getValue
();
115
}
116
}
MediaWiki\Block\Restriction\AbstractRestriction
Definition
AbstractRestriction.php:11
MediaWiki\Block\Restriction\AbstractRestriction\setBlockId
setBlockId( $blockId)
Set the ID of the block.1.33 self
Definition
AbstractRestriction.php:71
MediaWiki\Block\Restriction\AbstractRestriction\TYPE_ID
const TYPE_ID
Numeric type identifier.
Definition
AbstractRestriction.php:23
MediaWiki\Block\Restriction\AbstractRestriction\$value
int $value
Definition
AbstractRestriction.php:33
MediaWiki\Block\Restriction\AbstractRestriction\getBlockId
getBlockId()
Get the ID of the block.1.33 int
Definition
AbstractRestriction.php:64
MediaWiki\Block\Restriction\AbstractRestriction\$blockId
int $blockId
Definition
AbstractRestriction.php:28
MediaWiki\Block\Restriction\AbstractRestriction\toRow
toRow()
Convert a restriction object into a row array for insertion.1.33 array
Definition
AbstractRestriction.php:95
MediaWiki\Block\Restriction\AbstractRestriction\newFromRow
static newFromRow(\stdClass $row)
Create a new Restriction from a database row.1.33 static
Definition
AbstractRestriction.php:87
MediaWiki\Block\Restriction\AbstractRestriction\getValue
getValue()
Get the value of the restriction.1.33 int
Definition
AbstractRestriction.php:80
MediaWiki\Block\Restriction\AbstractRestriction\getType
static getType()
Get the type of restriction.1.33 string
Definition
AbstractRestriction.php:50
MediaWiki\Block\Restriction\AbstractRestriction\TYPE
const TYPE
String constant identifying the type of restriction.
Definition
AbstractRestriction.php:17
MediaWiki\Block\Restriction\AbstractRestriction\__construct
__construct( $blockId, $value)
Create Restriction.
Definition
AbstractRestriction.php:42
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:113
MediaWiki\Block\Restriction\AbstractRestriction\equals
equals(Restriction $other)
Determine if a restriction equals another restriction.1.33 bool
Definition
AbstractRestriction.php:106
MediaWiki\Block\Restriction\AbstractRestriction\getTypeId
static getTypeId()
Get the ID of the type of restriction.This ID is used in the database.1.33 int
Definition
AbstractRestriction.php:57
MediaWiki\Block\Restriction\Restriction
Definition
Restriction.php:13
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:9
includes
Block
Restriction
AbstractRestriction.php
Generated on Wed Dec 10 2025 08:48:57 for MediaWiki by
1.10.0