Pull out general functionality

This commit is contained in:
Dennis Eichhorn 2018-12-09 16:30:04 +01:00
parent 9cdb79ca9b
commit eac5fb4084

View File

@ -69,8 +69,7 @@ final class ApiController extends Controller
$ids[] = $file->getId(); $ids[] = $file->getId();
} }
$response->getHeader()->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true); $this->fillJsonRawResponse($request, $response, $ids);
$response->set($request->getUri()->__toString(), $ids);
} }
/** /**
@ -163,9 +162,15 @@ final class ApiController extends Controller
private static function normalizeDbPath(string $path) : string private static function normalizeDbPath(string $path) : string
{ {
$realpath = \realpath(__DIR__ . '/../../');
if ($realpath === false) {
throw new \Exception();
}
return \str_replace('\\', '/', return \str_replace('\\', '/',
\str_replace(realpath(__DIR__ . '/../../'), '', \str_replace($realpath, '',
rtrim($path, '/') \rtrim($path, '/')
) )
); );
} }