MediaWiki REL1_33
AbstractRestriction.php
Go to the documentation of this file.
1<?php
24
25abstract class AbstractRestriction implements Restriction {
26
30 const TYPE = '';
31
35 const TYPE_ID = 0;
36
40 protected $blockId;
41
45 protected $value;
46
54 public function __construct( $blockId, $value ) {
55 $this->blockId = (int)$blockId;
56 $this->value = (int)$value;
57 }
58
62 public static function getType() {
63 return static::TYPE;
64 }
65
69 public static function getTypeId() {
70 return static::TYPE_ID;
71 }
72
76 public function getBlockId() {
77 return $this->blockId;
78 }
79
83 public function setBlockId( $blockId ) {
84 $this->blockId = (int)$blockId;
85
86 return $this;
87 }
88
92 public function getValue() {
93 return $this->value;
94 }
95
99 public static function newFromRow( \stdClass $row ) {
100 // @phan-suppress-next-line PhanTypeInstantiateAbstract
101 return new static( $row->ir_ipb_id, $row->ir_value );
102 }
103
107 public function toRow() {
108 return [
109 'ir_ipb_id' => $this->getBlockId(),
110 'ir_type' => $this->getTypeId(),
111 'ir_value' => $this->getValue(),
112 ];
113 }
114
118 public function equals( Restriction $other ) {
119 return $this->getHash() === $other->getHash();
120 }
121
125 public function getHash() {
126 return $this->getType() . '-' . $this->getValue();
127 }
128}
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
__construct( $blockId, $value)
Create Restriction.
getHash()
Create a unique hash of the block restriction based on the type and value.