Refactor class names, #1065 allow reinstallation of SHOUTcast.
This commit is contained in:
parent
e74e2cc15c
commit
c26f6e980c
|
@ -13,6 +13,14 @@ return [
|
|||
]
|
||||
],
|
||||
|
||||
'current_version' => [
|
||||
'markup',
|
||||
[
|
||||
'label' => __('Current Installed Version'),
|
||||
'markup' => '<p class="text-danger">'.__('SHOUTcast is not currently installed on this installation.').'</p>',
|
||||
]
|
||||
],
|
||||
|
||||
'binary' => [
|
||||
'file',
|
||||
[
|
||||
|
|
|
@ -20,7 +20,7 @@ return function(App $app)
|
|||
$this->group('/install', function () {
|
||||
/** @var App $this */
|
||||
|
||||
$this->map(['GET', 'POST'], '/shoutcast', Controller\Admin\Install\ShoutcastController::class)
|
||||
$this->map(['GET', 'POST'], '/shoutcast', Controller\Admin\InstallShoutcastController::class)
|
||||
->setName('admin:install:shoutcast');
|
||||
|
||||
})->add([Middleware\Permissions::class, Acl::GLOBAL_ALL]);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
namespace App\Controller\Admin\Install;
|
||||
namespace App\Controller\Admin;
|
||||
|
||||
use App\Http\Request;
|
||||
use App\Http\Response;
|
||||
|
@ -7,7 +7,7 @@ use App\Radio\Frontend\SHOUTcast;
|
|||
use Psr\Http\Message\ResponseInterface;
|
||||
use Slim\Http\UploadedFile;
|
||||
|
||||
class ShoutcastController
|
||||
class InstallShoutcastController
|
||||
{
|
||||
/** @var array */
|
||||
protected $form_config;
|
||||
|
@ -23,13 +23,15 @@ class ShoutcastController
|
|||
|
||||
public function __invoke(Request $request, Response $response): ResponseInterface
|
||||
{
|
||||
if (SHOUTcast::isInstalled()) {
|
||||
return $request
|
||||
->getView()
|
||||
->renderToResponse($response, 'admin/install_shoutcast/installed');
|
||||
$form_config = $this->form_config;
|
||||
|
||||
$version = SHOUTcast::getVersion();
|
||||
|
||||
if (null !== $version) {
|
||||
$form_config['elements']['current_version'][1]['markup'] = '<p class="text-success">'.__('SHOUTcast version "%s" is currently installed.', $version).'</p>';
|
||||
}
|
||||
|
||||
$form = new \AzuraForms\Form($this->form_config, []);
|
||||
$form = new \AzuraForms\Form($form_config, []);
|
||||
|
||||
if ($request->isPost() && $form->isValid($_POST)) {
|
||||
try
|
||||
|
@ -42,16 +44,22 @@ class ShoutcastController
|
|||
|
||||
if ($import_file->getError() === \UPLOAD_ERR_OK) {
|
||||
$sc_tgz_path = $sc_base_dir.'/sc_serv.tar.gz';
|
||||
if (file_exists($sc_tgz_path)) {
|
||||
unlink($sc_tgz_path);
|
||||
}
|
||||
|
||||
$import_file->moveTo($sc_tgz_path);
|
||||
|
||||
$sc_tar_path = $sc_base_dir.'/sc_serv.tar';
|
||||
if (file_exists($sc_tar_path)) {
|
||||
unlink($sc_tar_path);
|
||||
}
|
||||
|
||||
$sc_tgz = new \PharData($sc_tgz_path);
|
||||
$sc_tgz->decompress();
|
||||
|
||||
$sc_tar_path = $sc_base_dir.'/sc_serv.tar';
|
||||
|
||||
$sc_tar = new \PharData($sc_tar_path);
|
||||
$sc_tar->extractTo($sc_base_dir);
|
||||
$sc_tar->extractTo($sc_base_dir, null, true);
|
||||
}
|
||||
|
||||
return $response->withRedirect($request->getUri()->getPath());
|
|
@ -119,11 +119,11 @@ class AdminProvider implements ServiceProviderInterface
|
|||
);
|
||||
};
|
||||
|
||||
$di[Admin\Install\ShoutcastController::class] = function($di) {
|
||||
$di[Admin\InstallShoutcastController::class] = function($di) {
|
||||
/** @var \Azura\Config $config */
|
||||
$config = $di[\Azura\Config::class];
|
||||
|
||||
return new Admin\Install\ShoutcastController(
|
||||
return new Admin\InstallShoutcastController(
|
||||
$config->get('forms/install_shoutcast')
|
||||
);
|
||||
};
|
||||
|
|
|
@ -9,7 +9,7 @@ use Monolog\Logger;
|
|||
use Supervisor\Process;
|
||||
use Supervisor\Supervisor;
|
||||
|
||||
abstract class AdapterAbstract
|
||||
abstract class AbstractAdapter
|
||||
{
|
||||
/** @var EntityManager */
|
||||
protected $em;
|
|
@ -150,7 +150,7 @@ class Adapters
|
|||
|
||||
if ($check_installed) {
|
||||
return array_filter($adapters, function($adapter_info) {
|
||||
/** @var \App\Radio\AdapterAbstract $adapter_class */
|
||||
/** @var \App\Radio\AbstractAdapter $adapter_class */
|
||||
$adapter_class = $adapter_info['class'];
|
||||
return $adapter_class::isInstalled();
|
||||
});
|
||||
|
@ -181,7 +181,7 @@ class Adapters
|
|||
|
||||
if ($check_installed) {
|
||||
return array_filter($adapters, function ($adapter_info) {
|
||||
/** @var \App\Radio\AdapterAbstract $adapter_class */
|
||||
/** @var \App\Radio\AbstractAdapter $adapter_class */
|
||||
$adapter_class = $adapter_info['class'];
|
||||
return $adapter_class::isInstalled();
|
||||
});
|
||||
|
|
|
@ -3,7 +3,7 @@ namespace App\Radio\Backend;
|
|||
|
||||
use App\Entity;
|
||||
|
||||
abstract class AbstractBackend extends \App\Radio\AdapterAbstract
|
||||
abstract class AbstractBackend extends \App\Radio\AbstractAdapter
|
||||
{
|
||||
public function getStreamPort(Entity\Station $station)
|
||||
{
|
||||
|
|
|
@ -12,7 +12,7 @@ use Monolog\Logger;
|
|||
use Psr\Http\Message\UriInterface;
|
||||
use Supervisor\Supervisor;
|
||||
|
||||
abstract class AbstractFrontend extends \App\Radio\AdapterAbstract
|
||||
abstract class AbstractFrontend extends \App\Radio\AbstractAdapter
|
||||
{
|
||||
/** @var Client */
|
||||
protected $http_client;
|
||||
|
|
|
@ -5,6 +5,7 @@ use App\Utilities;
|
|||
use Doctrine\ORM\EntityManager;
|
||||
use App\Entity;
|
||||
use Psr\Http\Message\UriInterface;
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
class SHOUTcast extends AbstractFrontend
|
||||
{
|
||||
|
@ -236,4 +237,25 @@ class SHOUTcast extends AbstractFrontend
|
|||
? $new_path
|
||||
: false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public static function getVersion(): ?string
|
||||
{
|
||||
$binary_path = self::getBinary();
|
||||
if (!$binary_path) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$process = new Process([$binary_path, '--version']);
|
||||
$process->setWorkingDirectory(dirname($binary_path));
|
||||
$process->run();
|
||||
|
||||
if (!$process->isSuccessful()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return trim($process->getOutput());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue