8 namespace Fossology\UI\Api\Controllers;
16 use Psr\Http\Message\ServerRequestInterface;
38 public function createMaintenance($request, $response, $args)
44 if (empty($body[
'options'])) {
49 if (!is_array($body[
'options'])) {
52 if (in_array(
"o",$body[
"options"]) && empty($body[
"goldDate"])) {
55 if (in_array(
"l",$body[
"options"]) && empty($body[
"logsDate"])) {
59 $body[
'options'] = array_unique($body[
'options']);
60 $alteredOptions = array();
62 $maintain = $this->restHelper->getPlugin(
'maintagent');
63 $existingOptions = $maintain->getOptions();
66 foreach ($body[
'options'] as $key) {
67 if (!array_key_exists($key, $existingOptions)) {
70 $alteredOptions[$key] = $key;
73 $body[
'options'] = $alteredOptions;
74 $mess = $maintain->handle($body);
75 $returnVal =
new Info(201, $mess, InfoType::INFO);
76 return $response->withJson($returnVal->getArray(), $returnVal->getCode());
Base controller for REST calls.
getParsedBody(ServerRequestInterface $request)
Parse request body as JSON and return associative PHP array.
Override Slim response for withJson function.
Different type of infos provided by REST.
Info model to contain general error and return values.