36 lines
No EOL
945 B
PHP
36 lines
No EOL
945 B
PHP
<?php
|
|
|
|
namespace OCA\SCIMServiceProvider\Responses;
|
|
|
|
use OCP\AppFramework\Http\JSONResponse;
|
|
|
|
use OCA\SCIMServiceProvider\Exceptions\SCIMException;
|
|
|
|
/**
|
|
* Class SCIMListResponse
|
|
*
|
|
*/
|
|
class SCIMListResponse extends JSONResponse {
|
|
/**
|
|
* Returns the rendered json
|
|
* @return string the rendered json
|
|
* @since 6.0.0
|
|
* @throws \Exception If data could not get encoded
|
|
*/
|
|
public function render() {
|
|
$scimReponse = [
|
|
'schemas' => ['urn:ietf:params:scim:api:messages:2.0:ListResponse'],
|
|
'startIndex' => 1, // todo pagination
|
|
'Resources' => $this->data,
|
|
'totalResults' => sizeof($this->data)
|
|
];
|
|
$response = json_encode($scimReponse, JSON_UNESCAPED_SLASHES);
|
|
|
|
if ($response === false) {
|
|
throw new SCIMException(sprintf('Could not json_encode due to invalid ' .
|
|
'non UTF-8 characters in the array: %s', var_export($scimReponse, true)));
|
|
}
|
|
|
|
return $response;
|
|
}
|
|
} |