Skip to content

Commit 0def9d5

Browse files
committed
integration with flysystem rdf content negotiation
1 parent 23596a4 commit 0def9d5

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

web/index.php

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
use Pdsinterop\Solid\Controller\Profile\ProfileController;
3232
use Pdsinterop\Solid\Controller\RegisterController;
3333
use Pdsinterop\Solid\Controller\ResourceController;
34+
use Pdsinterop\Solid\Controller\StorageController;
3435
use Pdsinterop\Solid\Controller\TokenController;
3536
use Pdsinterop\Solid\Resources\Server as ResourceServer;
3637

@@ -54,21 +55,40 @@
5455
$container->add(ServerRequestInterface::class, Request::class);
5556
$container->add(ResponseInterface::class, Response::class);
5657

58+
/*
5759
$adapter = new \League\Flysystem\Adapter\Local(__DIR__ . '/../tests/fixtures');
5860
$filesystem = new \League\Flysystem\Filesystem($adapter);
5961
$graph = new \EasyRdf_Graph();
6062
$plugin = new \Pdsinterop\Rdf\Flysystem\Plugin\ReadRdf($graph);
6163
$filesystem->addPlugin($plugin);
64+
*/
6265

63-
$container->share(FilesystemInterface::class, function () {
66+
$container->share(FilesystemInterface::class, function () use ($request) {
6467
// @FIXME: Filesystem root and the $adapter should be configurable.
6568
// Implement this with `$filesystem = \MJRider\FlysystemFactory\create(getenv('STORAGE_ENDPOINT'));`
6669
$filesystemRoot = __DIR__ . '/../tests/fixtures';
6770

6871
$adapter = new \League\Flysystem\Adapter\Local($filesystemRoot);
6972

70-
$filesystem = new \League\Flysystem\Filesystem($adapter);
7173
$graph = new \EasyRdf_Graph();
74+
75+
// Create Formats objects
76+
$formats = new \Pdsinterop\Rdf\Formats();
77+
78+
$serverUri = "https://server" . $request->getServerParams()["REQUEST_URI"]; // FIXME: doublecheck that this is the correct url;
79+
80+
// Create the RDF Adapter
81+
$rdfAdapter = new \Pdsinterop\Rdf\Flysystem\Adapter\Rdf(
82+
$adapter,
83+
$graph,
84+
$formats,
85+
$serverUri
86+
);
87+
88+
$filesystem = new \League\Flysystem\Filesystem($rdfAdapter);
89+
90+
$filesystem->addPlugin(new \Pdsinterop\Rdf\Flysystem\Plugin\AsMime($formats));
91+
7292
$plugin = new \Pdsinterop\Rdf\Flysystem\Plugin\ReadRdf($graph);
7393
$filesystem->addPlugin($plugin);
7494

@@ -104,6 +124,7 @@
104124
OpenidController::class,
105125
ProfileController::class,
106126
RegisterController::class,
127+
StorageController::class,
107128
TokenController::class,
108129
];
109130

@@ -170,6 +191,7 @@
170191

171192
array_walk($methods, static function ($method) use (&$group) {
172193
$group->map($method, '/', AddSlashToPathController::class);
194+
// $group->map($method, '//', StorageController::class);
173195
$group->map($method, '{path:.*}', ResourceController::class);
174196
});
175197
})->setScheme($scheme);

0 commit comments

Comments
 (0)