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
{
44 public function __construct( $blockId, $value ) {
45 $this->blockId
= (int)$blockId;
46 $this->value
= (int)$value;
52 public function getBlockId() {
53 return $this->blockId
;
59 public function setBlockId( $blockId ) {
60 $this->blockId
= (int)$blockId;
68 public function getValue() {
75 public static function newFromRow( \stdClass
$row ) {
76 return new static( $row->ir_ipb_id
, $row->ir_value
);
82 public function toRow() {
84 'ir_ipb_id' => $this->getBlockId(),
85 'ir_type' => $this->getTypeId(),
86 'ir_value' => $this->getValue(),
93 public function equals( Restriction
$other ) {
94 return $this->getHash() === $other->getHash();
100 public function getHash() {
101 return $this->getType() . '-' . $this->getValue();