| 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 | use MediaWiki\Title\Title; |
| 26 | |
| 27 | interface Restriction { |
| 28 | |
| 29 | /** |
| 30 | * Get the ID of the block. |
| 31 | * |
| 32 | * @since 1.33 |
| 33 | * @return int |
| 34 | */ |
| 35 | public function getBlockId(); |
| 36 | |
| 37 | /** |
| 38 | * Set the ID of the block. |
| 39 | * |
| 40 | * @since 1.33 |
| 41 | * @param int $blockId |
| 42 | * @return self |
| 43 | */ |
| 44 | public function setBlockId( $blockId ); |
| 45 | |
| 46 | /** |
| 47 | * Get the value of the restriction. |
| 48 | * |
| 49 | * @since 1.33 |
| 50 | * @return int |
| 51 | */ |
| 52 | public function getValue(); |
| 53 | |
| 54 | /** |
| 55 | * Get the type of restriction |
| 56 | * |
| 57 | * @since 1.33 |
| 58 | * @return string |
| 59 | */ |
| 60 | public static function getType(); |
| 61 | |
| 62 | /** |
| 63 | * Get the ID of the type of restriction. This ID is used in the database. |
| 64 | * |
| 65 | * @since 1.33 |
| 66 | * @return int |
| 67 | */ |
| 68 | public static function getTypeId(); |
| 69 | |
| 70 | /** |
| 71 | * Create a new Restriction from a database row. |
| 72 | * |
| 73 | * @since 1.33 |
| 74 | * @param \stdClass $row |
| 75 | * @return static |
| 76 | */ |
| 77 | public static function newFromRow( \stdClass $row ); |
| 78 | |
| 79 | /** |
| 80 | * Convert a restriction object into a row array for insertion. |
| 81 | * |
| 82 | * @since 1.33 |
| 83 | * @return array |
| 84 | */ |
| 85 | public function toRow(); |
| 86 | |
| 87 | /** |
| 88 | * Determine if a restriction matches a given title. |
| 89 | * |
| 90 | * @since 1.33 |
| 91 | * @param Title $title |
| 92 | * @return bool |
| 93 | */ |
| 94 | public function matches( Title $title ); |
| 95 | |
| 96 | /** |
| 97 | * Determine if a restriction equals another restriction. |
| 98 | * |
| 99 | * @since 1.33 |
| 100 | * @param Restriction $other |
| 101 | * @return bool |
| 102 | */ |
| 103 | public function equals( Restriction $other ); |
| 104 | |
| 105 | /** |
| 106 | * Create a unique hash of the block restriction based on the type and value. |
| 107 | * |
| 108 | * @since 1.33 |
| 109 | * @return string |
| 110 | */ |
| 111 | public function getHash(); |
| 112 | |
| 113 | } |