wiki.techinc.nl/includes/block/Restriction/NamespaceRestriction.php
David Barratt be27181956 Add NamespaceRestriction class so that BlockRestriction can handle namespaces.
This begins work on making namespaces a valid restriction type. The CRUD
operations of BlockRestriction can now handle namespaces. Since
NamespaceRestriction implements Restriction, enforcement should start working
immediately, but testing enforcement will come in a subsequent patch since it's
impossible to create them.

Bug: T204991
Change-Id: I7264b452d9ad788c146d6ea25d01d4d7cb5ac4f6
2019-01-21 14:19:39 +00:00

44 lines
1.1 KiB
PHP

<?php
/**
* A Block restriction object of type 'Namespace'.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
* @file
*/
namespace MediaWiki\Block\Restriction;
class NamespaceRestriction extends AbstractRestriction {
/**
* {@inheritdoc}
*/
const TYPE = 'ns';
/**
* {@inheritdoc}
*/
const TYPE_ID = 2;
/**
* {@inheritdoc}
*/
public function matches( \Title $title ) {
return $this->getValue() === $title->getNamespace();
}
}