Skip to content

Commit 212b85b

Browse files
committed
Change index.php to be cleaner.
1 parent e399baa commit 212b85b

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

web/index.php

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,17 @@
6868
// Create Formats objects
6969
$formats = new \Pdsinterop\Rdf\Formats();
7070

71-
$serverUri = "https://" . $request->getServerParams()["SERVER_NAME"] . $request->getServerParams()["REQUEST_URI"]; // FIXME: doublecheck that this is the correct url;
71+
$serverParams = $request->getServerParams();
72+
73+
$serverUri = '';
74+
if (isset($serverParams['SERVER_NAME'])) {
75+
$serverUri = vsprintf("%s://%s%s", [
76+
// FIXME: doublecheck that this is the correct url;
77+
getenv('PROXY_MODE') ? 'http' : 'https',
78+
$serverParams['SERVER_NAME'],
79+
$serverParams['REQUEST_URI'] ?? '',
80+
]);
81+
}
7282

7383
// Create the RDF Adapter
7484
$rdfAdapter = new \Pdsinterop\Rdf\Flysystem\Adapter\Rdf(
@@ -77,11 +87,11 @@
7787
$formats,
7888
$serverUri
7989
);
80-
90+
8191
$filesystem = new \League\Flysystem\Filesystem($rdfAdapter);
8292

8393
$filesystem->addPlugin(new \Pdsinterop\Rdf\Flysystem\Plugin\AsMime($formats));
84-
94+
8595
$plugin = new \Pdsinterop\Rdf\Flysystem\Plugin\ReadRdf($graph);
8696
$filesystem->addPlugin($plugin);
8797

@@ -90,7 +100,7 @@
90100

91101
$container->share(\PHPTAL::class, function () {
92102
$template = new \PHPTAL();
93-
$template->setTemplateRepository(__DIR__.'/../src/Template');
103+
$template->setTemplateRepository(__DIR__ . '/../src/Template');
94104
return $template;
95105
});
96106

@@ -134,12 +144,12 @@
134144

135145
$traitMethods = array_keys($traits);
136146

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

140150
$methods = get_class_methods($controller);
141151

142-
array_walk ($methods, function ($method) use ($definition, $traitMethods, $traits) {
152+
array_walk ($methods, static function ($method) use ($definition, $traitMethods, $traits) {
143153
if (in_array($method, $traitMethods, true)) {
144154
$definition->addMethodCall($method, $traits[$method]);
145155
}

0 commit comments

Comments
 (0)