mirror of https://github.com/Rudloff/alltube.git
Fix warnings
This commit is contained in:
parent
18e6f4bcc1
commit
d3d9681b5f
|
@ -320,5 +320,4 @@ class Config
|
|||
|
||||
return $version->getPrettyVersion();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -63,25 +63,38 @@ class ViewFactory
|
|||
return $view;
|
||||
}
|
||||
|
||||
static function extractHeader(Request $request = null, string $headerName) {
|
||||
/**
|
||||
* Extract the header name from the given request.
|
||||
* Multiple headers with the same name are not supported; the first one would be returned in this case.
|
||||
*
|
||||
* @param Request|null $request PSR-7 request
|
||||
* @param string $headerName name of the header
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public static function extractHeader(Request $request = null, string $headerName)
|
||||
{
|
||||
if (is_null($request)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$header = $request->getHeader($headerName);
|
||||
if (!isset($header)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$count = sizeof($header);
|
||||
if ($count != 1) {
|
||||
if ($count < 1) {
|
||||
return null;
|
||||
}
|
||||
return $header[0];
|
||||
}
|
||||
|
||||
public static function getBasePath(Request $request = null) {
|
||||
/**
|
||||
* Get the basepath as specified via 'X-Forwarded-Path' from the request if present.
|
||||
*
|
||||
* @param Request|null $request PSR-7 request
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public static function getBasePath(Request $request = null)
|
||||
{
|
||||
return ViewFactory::extractHeader($request, 'X-Forwarded-Path');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
14
index.php
14
index.php
|
@ -33,8 +33,6 @@ try {
|
|||
|
||||
$app->add(new LocaleMiddleware($container));
|
||||
|
||||
$container['config'] = $config;
|
||||
|
||||
// Smarty.
|
||||
$container['view'] = ViewFactory::create($container);
|
||||
|
||||
|
@ -60,32 +58,32 @@ $container['config'] = $config;
|
|||
)->setName('index');
|
||||
|
||||
$app->get(
|
||||
$base_path . '/extractors',
|
||||
$basePath . '/extractors',
|
||||
[$frontController, 'extractors']
|
||||
)->setName('extractors');
|
||||
|
||||
$app->any(
|
||||
$base_path . '/info',
|
||||
$basePath . '/info',
|
||||
[$frontController, 'info']
|
||||
)->setName('info');
|
||||
|
||||
$app->any(
|
||||
$base_path . '/watch',
|
||||
$basePath . '/watch',
|
||||
[$frontController, 'info']
|
||||
);
|
||||
|
||||
$app->any(
|
||||
$base_path . '/download',
|
||||
$basePath . '/download',
|
||||
[$downloadController, 'download']
|
||||
)->setName('download');
|
||||
|
||||
$app->get(
|
||||
$base_path . '/locale/{locale}',
|
||||
$basePath . '/locale/{locale}',
|
||||
[$frontController, 'locale']
|
||||
)->setName('locale');
|
||||
|
||||
$app->get(
|
||||
$base_path . '/json',
|
||||
$basePath . '/json',
|
||||
[$jsonController, 'json']
|
||||
)->setName('json');
|
||||
|
||||
|
|
|
@ -40,7 +40,6 @@ class ConfigTest extends BaseTest
|
|||
$this->assertIsString($config->youtubedl);
|
||||
$this->assertIsString($config->python);
|
||||
$this->assertIsString($config->ffmpeg);
|
||||
$this->assertIsString($config->basePath);
|
||||
$this->assertIsBool($config->convert);
|
||||
$this->assertIsBool($config->uglyUrls);
|
||||
$this->assertIsBool($config->stream);
|
||||
|
@ -48,7 +47,6 @@ class ConfigTest extends BaseTest
|
|||
$this->assertIsBool($config->defaultAudio);
|
||||
$this->assertIsBool($config->convertSeek);
|
||||
$this->assertIsInt($config->audioBitrate);
|
||||
$this->assertIsInt($config->forwardPort);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -124,16 +122,4 @@ class ConfigTest extends BaseTest
|
|||
$this->assertEquals(true, $config->convert);
|
||||
putenv('CONVERT');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the getBasePath function.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testGetBasePath()
|
||||
{
|
||||
Config::setOptions(['basePath' => '/foo']);
|
||||
$config = Config::getInstance();
|
||||
$this->assertEquals('/foo', $config->getBasePath(null, null));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue