3 * Abstract block restriction.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
23 namespace MediaWiki\Block\Restriction
;
25 abstract class AbstractRestriction
implements Restriction
{
54 public function __construct( $blockId, $value ) {
55 $this->blockId
= (int)$blockId;
56 $this->value
= (int)$value;
62 public static function getType() {
69 public static function getTypeId() {
70 return static::TYPE_ID
;
76 public function getBlockId() {
77 return $this->blockId
;
83 public function setBlockId( $blockId ) {
84 $this->blockId
= (int)$blockId;
92 public function getValue() {
99 public static function newFromRow( \stdClass
$row ) {
100 return new static( $row->ir_ipb_id
, $row->ir_value
);
106 public function toRow() {
108 'ir_ipb_id' => $this->getBlockId(),
109 'ir_type' => $this->getTypeId(),
110 'ir_value' => $this->getValue(),
117 public function equals( Restriction
$other ) {
118 return $this->getHash() === $other->getHash();
124 public function getHash() {
125 return $this->getType() . '-' . $this->getValue();