Merge "Add editing own JSON to editmyoptions grant"
[lhc/web/wiklou.git] / includes / block / Restriction / Restriction.php
1 <?php
2 /**
3 * Block restriction interface.
4 *
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.
9 *
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.
14 *
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
19 *
20 * @file
21 */
22
23 namespace MediaWiki\Block\Restriction;
24
25 interface Restriction {
26
27 /**
28 * Gets the id of the block.
29 *
30 * @return int
31 */
32 public function getBlockId();
33
34 /**
35 * Sets the id of the block.
36 *
37 * @param int $blockId
38 * @return self
39 */
40 public function setBlockId( $blockId );
41
42 /**
43 * Gets the value of the restriction.
44 *
45 * @return int
46 */
47 public function getValue();
48
49 /**
50 * Gets the type of restriction
51 *
52 * @return string
53 */
54 public function getType();
55
56 /**
57 * Gets the id of the type of restriction. This id is used in the database.
58 *
59 * @return string
60 */
61 public function getTypeId();
62
63 /**
64 * Creates a new Restriction from a database row.
65 *
66 * @param \stdClass $row
67 * @return self
68 */
69 public static function newFromRow( \stdClass $row );
70
71 /**
72 * Convert a restriction object into a row array for insertion.
73 *
74 * @return array
75 */
76 public function toRow();
77
78 /**
79 * Determine if a restriction matches a given title.
80 *
81 * @param \Title $title
82 * @return bool
83 */
84 public function matches( \Title $title );
85
86 /**
87 * Determine if a restriction equals another restriction.
88 *
89 * @param Restriction $other
90 * @return bool
91 */
92 public function equals( Restriction $other );
93
94 /**
95 * Create a unique hash of the block restriction based on the type and value.
96 *
97 * @return string
98 */
99 public function getHash();
100
101 }