Page MenuHomeWickedGov Phorge

UnsupportedContentTypeBodyValidator.php
No OneTemporary

Size
978 B
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 {
private string $contentType;
public function __construct( string $contentType ) {
$this->contentType = $contentType;
}
/**
* @inheritDoc
* @return never
*/
public function validateBody( RequestInterface $request ): never {
throw new LocalizedHttpException(
new MessageValue( 'rest-unsupported-content-type', [ $this->contentType ] ),
415
);
}
}

File Metadata

Mime Type
text/x-php
Expires
Aug 15 2026, 12:18 (12 w, 4 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
0c/94/d18ec03212c412c5ce819e5b6599
Default Alt Text
UnsupportedContentTypeBodyValidator.php (978 B)

Event Timeline