Page MenuHomeWickedGov Phorge

UnsupportedContentTypeBodyValidator.php
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

UnsupportedContentTypeBodyValidator.php

<?php
namespace MediaWiki\Rest\Validator;
use MediaWiki\Rest\LocalizedHttpException;
use MediaWiki\Rest\RequestInterface;
use Wikimedia\Message\MessageValue;
/**
* Validator that always fails. Meant as a convenience for Handler::getBodyValidator():
*
* public function getBodyValidator( $contentType ) {
* if ( $contentType === 'supported/content-type' ) {
* return new MyValidator();
* }
* return new UnsupportedContentTypeBodyValidator( $contentType );
* }
*
* @since 1.40
*/
class UnsupportedContentTypeBodyValidator implements BodyValidator {
/** @var string */
private string $contentType;
/**
* @param string $contentType
*/
public function __construct( string $contentType ) {
$this->contentType = $contentType;
}
/**
* @inheritDoc
* @return never
*/
public function validateBody( RequestInterface $request ) {
throw new LocalizedHttpException(
new MessageValue( 'rest-unsupported-content-type', [ $this->contentType ] ),
415
);
}
}

File Metadata

Mime Type
text/x-php
Expires
Sat, Oct 3, 12:07 (3 d, 12 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
de/60/9336abccb97c0c90e9d11b8f1309
Default Alt Text
UnsupportedContentTypeBodyValidator.php (1 KB)

Event Timeline