|
6 | 6 | use EasyRdf_Graph as Graph; |
7 | 7 | use Laminas\Diactoros\ServerRequest; |
8 | 8 | use League\Flysystem\FilesystemInterface as Filesystem; |
9 | | -use LogicException; |
10 | 9 | use Psr\Http\Message\ResponseInterface as Response; |
11 | 10 | use Psr\Http\Message\ServerRequestInterface as Request; |
12 | 11 | use Throwable; |
@@ -147,8 +146,8 @@ private function handle(string $method, string $path, $contents, $request): Resp |
147 | 146 | // @FIXME: Add correct headers to resources (for instance allow DELETE on a GET resource) |
148 | 147 | // ->withAddedHeader('Accept-Patch', 'text/ldpatch') |
149 | 148 | // ->withAddedHeader('Accept-Post', 'text/turtle, application/ld+json, image/bmp, image/jpeg') |
150 | | - // ->withHeader('Allow', 'GET, HEAD, OPTIONS, PATCH, POST, PUT'); |
151 | | - // ; |
| 149 | + // ->withHeader('Allow', 'GET, HEAD, OPTIONS, PATCH, POST, PUT') |
| 150 | + //; |
152 | 151 |
|
153 | 152 | switch ($method) { |
154 | 153 | case 'DELETE': |
@@ -249,8 +248,7 @@ private function handle(string $method, string $path, $contents, $request): Resp |
249 | 248 | } |
250 | 249 | break; |
251 | 250 | default: |
252 | | - $message = vsprintf(self::ERROR_UNKNOWN_HTTP_METHOD, [$method]); |
253 | | - throw new LogicException($message); |
| 251 | + throw Exception::create(self::ERROR_UNKNOWN_HTTP_METHOD, [$method]); |
254 | 252 | break; |
255 | 253 | } |
256 | 254 |
|
@@ -303,15 +301,15 @@ private function handleSparqlUpdate(Response $response, string $path, $contents) |
303 | 301 | foreach ($values as $value) { |
304 | 302 | $count = $graph->delete($resource, $property, $value); |
305 | 303 | if ($count === 0) { |
306 | | - throw new \Exception("Could not delete a value", 500); |
| 304 | + throw new Exception("Could not delete a value", 500); |
307 | 305 | } |
308 | 306 | } |
309 | 307 | } |
310 | 308 | } |
311 | 309 | } |
312 | 310 | break; |
313 | 311 | default: |
314 | | - throw new \Exception("Unimplemented SPARQL", 500); |
| 312 | + throw new Exception("Unimplemented SPARQL", 500); |
315 | 313 | break; |
316 | 314 | } |
317 | 315 | } |
@@ -500,6 +498,7 @@ private function getRequestedMimeType($accept) |
500 | 498 | private function handleReadRequest(Response $response, string $path, $contents, $mime=''): Response |
501 | 499 | { |
502 | 500 | $filesystem = $this->filesystem; |
| 501 | + |
503 | 502 | if ($path === "/") { // FIXME: this is a patch to make it work for Solid-Nextcloud; we should be able to just list '/'; |
504 | 503 | $contents = $this->listDirectoryAsTurtle($path); |
505 | 504 | $response->getBody()->write($contents); |
@@ -591,7 +590,7 @@ private function listDirectoryAsTurtle($path) |
591 | 590 | $turtle["<>"]['ldp:contains'][] = $filename; |
592 | 591 | break; |
593 | 592 | default: |
594 | | - throw new \Exception("Unknown type", 500); |
| 593 | + throw new Exception("Unknown type", 500); |
595 | 594 | break; |
596 | 595 | } |
597 | 596 | } |
|
0 commit comments