diff --git a/plugin/ims_lti/src/ImsLtiServiceRequestFactory.php b/plugin/ims_lti/src/ImsLtiServiceRequestFactory.php index 8c8dd4967a..0756e96aab 100644 --- a/plugin/ims_lti/src/ImsLtiServiceRequestFactory.php +++ b/plugin/ims_lti/src/ImsLtiServiceRequestFactory.php @@ -16,13 +16,19 @@ class ImsLtiServiceRequestFactory $bodyChildren = $xml->imsx_POXBody->children(); if (!empty($bodyChildren)) { - switch ($bodyChildren->getName()) { + $name = $bodyChildren->getName(); + + switch ($name) { case 'replaceResultRequest': return new ImsLtiServiceReplaceRequest($xml); case 'readResultRequest': return new ImsLtiServiceReadRequest($xml); case 'deleteResultRequest': return new ImsLtiServiceDeleteRequest($xml); + default: + $name = str_replace(['ResultRequest', 'Request'], '', $name); + + return new ImsLtiServiceUnsupportedRequest($xml, $name); } } diff --git a/plugin/ims_lti/src/ImsLtiServiceResponseFactory.php b/plugin/ims_lti/src/ImsLtiServiceResponseFactory.php index 9cac5508f0..cb8b0ae516 100644 --- a/plugin/ims_lti/src/ImsLtiServiceResponseFactory.php +++ b/plugin/ims_lti/src/ImsLtiServiceResponseFactory.php @@ -22,6 +22,8 @@ class ImsLtiServiceResponseFactory return new ImsLtiServiceReadResponse($statusInfo, $bodyParam); case ImsLtiServiceResponse::TYPE_DELETE: return new ImsLtiServiceDeleteResponse($statusInfo, $bodyParam); + default: + return new ImsLtiServiceUnsupportedResponse($statusInfo, $type); } return null; diff --git a/plugin/ims_lti/src/ImsLtiServiceResponseStatus.php b/plugin/ims_lti/src/ImsLtiServiceResponseStatus.php index 5f06c2bf91..4fb535d488 100644 --- a/plugin/ims_lti/src/ImsLtiServiceResponseStatus.php +++ b/plugin/ims_lti/src/ImsLtiServiceResponseStatus.php @@ -13,7 +13,7 @@ class ImsLtiServiceResponseStatus const CODEMAJOR_SUCCESS = 'success'; const CODEMAJOR_PROCESSING = 'processing'; const CODEMAJOR_FAILURE = 'failure'; - const CODEMAJOR_UNSUPPORTED = 'supported'; + const CODEMAJOR_UNSUPPORTED = 'unsupported'; /** * @var string diff --git a/plugin/ims_lti/src/ImsLtiServiceUnsupportedRequest.php b/plugin/ims_lti/src/ImsLtiServiceUnsupportedRequest.php new file mode 100644 index 0000000000..28f79f4d6e --- /dev/null +++ b/plugin/ims_lti/src/ImsLtiServiceUnsupportedRequest.php @@ -0,0 +1,31 @@ +responseType = $name; + } + + protected function processBody() + { + $this->statusInfo + ->setSeverity(ImsLtiServiceResponseStatus::SEVERITY_STATUS) + ->setCodeMajor(ImsLtiServiceResponseStatus::CODEMAJOR_UNSUPPORTED) + ->setDescription( + $this->responseType.' is not supported' + ); + } +} diff --git a/plugin/ims_lti/src/ImsLtiServiceUnsupportedResponse.php b/plugin/ims_lti/src/ImsLtiServiceUnsupportedResponse.php new file mode 100644 index 0000000000..1d45f583cb --- /dev/null +++ b/plugin/ims_lti/src/ImsLtiServiceUnsupportedResponse.php @@ -0,0 +1,28 @@ +setOperationRefIdentifier($type); + + parent::__construct($statusInfo); + } + + /** + * @param SimpleXMLElement $xmlBody + */ + protected function generateBody(SimpleXMLElement $xmlBody) + { + } +}