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
{
43 public function __construct( $blockId, $value ) {
44 $this->blockId
= (int)$blockId;
45 $this->value
= (int)$value;
51 public function getBlockId() {
52 return $this->blockId
;
58 public function setBlockId( $blockId ) {
59 $this->blockId
= (int)$blockId;
67 public function getValue() {
74 public static function newFromRow( \stdClass
$row ) {
75 return new static( $row->ir_ipb_id
, $row->ir_value
);
81 public function toRow() {
83 'ir_ipb_id' => $this->getBlockId(),
84 'ir_type' => $this->getTypeId(),
85 'ir_value' => $this->getValue(),
92 public function equals( Restriction
$other ) {
93 return $this->getHash() === $other->getHash();
99 public function getHash() {
100 return $this->getType() . '-' . $this->getValue();