Updated all dependencies and prepared for PHP 8

This commit is contained in:
2026-06-19 09:37:22 +00:00
parent 941c9104dc
commit 5f9f6ca2ff
21 changed files with 3334 additions and 2643 deletions
+11 -10
View File
@@ -3,12 +3,12 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
namespace CloudObjects\PhpMAE;
use Psr\Container\ContainerInterface;
use Psr\Http\Message\RequestInterface;
use Slim\Http\Response;
use Slim\Psr7\Response;
use ML\IRI\IRI;
use ML\JsonLD\JsonLD;
use CloudObjects\Utilities\RDF\Arc2JsonLdConverter;
@@ -23,14 +23,14 @@ class UploadController {
public function __construct(ContainerInterface $container, ObjectRetriever $objectRetriever,
ClassRepository $classRepository) {
$this->container = $container;
$this->objectRetriever = $objectRetriever;
$this->classRepository = $classRepository;
}
}
private function uploadSource(RequestInterface $request) {
$object = $this->objectRetriever->get($request->getQueryParam('coid'));
$object = $this->objectRetriever->get($request->getQueryParams()['coid'] ?? null);
if (!$object)
throw new PhpMAEException("Unable to retrieve object.");
@@ -42,10 +42,11 @@ class UploadController {
new IRI($object->getId()),
TypeChecker::getAdditionalTypes($object));
} catch (\Exception $e) {
$response = (new Response(400))->withJson([
$response = (new Response(400))->withHeader('Content-Type', 'application/json');
$response->getBody()->write(json_encode([
'error_code' => get_class($e),
'error_message' => $e->getMessage()
]);
]));
return $response;
}
@@ -67,12 +68,12 @@ class UploadController {
// Validate config
if (!isset($jsonLdConfig->{'@id'})
|| $jsonLdConfig->{'@id'} != $request->getQueryParam('coid')) {
|| $jsonLdConfig->{'@id'} != ($request->getQueryParams()['coid'] ?? null)) {
throw new PhpMAEException("Uploaded configuration does not correspond to object.");
}
// Store configuration
$iri = new IRI($request->getQueryParam('coid'));
$iri = new IRI($request->getQueryParams()['coid'] ?? null);
$path = $this->container->get('uploads_dir')
.DIRECTORY_SEPARATOR.'config'
.DIRECTORY_SEPARATOR.$iri->getHost()
@@ -91,7 +92,7 @@ class UploadController {
if ($request->getMethod() != 'PUT')
throw new PhpMAEException("Must use PUT for uploading to test environment.");
switch ($request->getQueryParam('type')) {
switch ($request->getQueryParams()['type'] ?? null) {
case "source":
return $this->uploadSource($request);
break;