Skip to content

Commit

Permalink
Change index.php to be cleaner.
Browse files Browse the repository at this point in the history
  • Loading branch information
Potherca committed Jan 12, 2022
1 parent e399baa commit 212b85b
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions web/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,17 @@
// Create Formats objects
$formats = new \Pdsinterop\Rdf\Formats();

$serverUri = "https://" . $request->getServerParams()["SERVER_NAME"] . $request->getServerParams()["REQUEST_URI"]; // FIXME: doublecheck that this is the correct url;
$serverParams = $request->getServerParams();

$serverUri = '';
if (isset($serverParams['SERVER_NAME'])) {
$serverUri = vsprintf("%s://%s%s", [
// FIXME: doublecheck that this is the correct url;
getenv('PROXY_MODE') ? 'http' : 'https',
$serverParams['SERVER_NAME'],
$serverParams['REQUEST_URI'] ?? '',
]);
}

// Create the RDF Adapter
$rdfAdapter = new \Pdsinterop\Rdf\Flysystem\Adapter\Rdf(
Expand All @@ -77,11 +87,11 @@
$formats,
$serverUri
);

$filesystem = new \League\Flysystem\Filesystem($rdfAdapter);

$filesystem->addPlugin(new \Pdsinterop\Rdf\Flysystem\Plugin\AsMime($formats));

$plugin = new \Pdsinterop\Rdf\Flysystem\Plugin\ReadRdf($graph);
$filesystem->addPlugin($plugin);

Expand All @@ -90,7 +100,7 @@

$container->share(\PHPTAL::class, function () {
$template = new \PHPTAL();
$template->setTemplateRepository(__DIR__.'/../src/Template');
$template->setTemplateRepository(__DIR__ . '/../src/Template');
return $template;
});

Expand Down Expand Up @@ -134,12 +144,12 @@

$traitMethods = array_keys($traits);

array_walk($controllers, function ($controller) use ($container, $traits, $traitMethods) {
array_walk($controllers, static function ($controller) use ($container, $traits, $traitMethods) {
$definition = $container->add($controller);

$methods = get_class_methods($controller);

array_walk ($methods, function ($method) use ($definition, $traitMethods, $traits) {
array_walk ($methods, static function ($method) use ($definition, $traitMethods, $traits) {
if (in_array($method, $traitMethods, true)) {
$definition->addMethodCall($method, $traits[$method]);
}
Expand Down

0 comments on commit 212b85b

Please sign in to comment.