75 lines
2.0 KiB
PHP
75 lines
2.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Console\Command;
|
|
|
|
use App\Entity;
|
|
use App\Environment;
|
|
use Symfony\Component\Console\Attribute\AsCommand;
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
|
|
|
#[AsCommand(
|
|
name: 'azuracast:setup:initialize',
|
|
description: 'Ensure key settings are initialized within AzuraCast.',
|
|
)]
|
|
class InitializeCommand extends CommandAbstract
|
|
{
|
|
public function __construct(
|
|
protected Environment $environment,
|
|
protected Entity\Repository\StorageLocationRepository $storageLocationRepo,
|
|
) {
|
|
parent::__construct();
|
|
}
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
|
{
|
|
$io = new SymfonyStyle($input, $output);
|
|
|
|
$io->title(__('Initialize AzuraCast'));
|
|
$io->writeln(__('Initializing essential settings...'));
|
|
|
|
$io->listing(
|
|
[
|
|
__('Environment: %s', $this->environment->getAppEnvironmentEnum()->getName()),
|
|
__('Installation Method: %s', $this->environment->isDocker() ? 'Docker' : 'Ansible'),
|
|
]
|
|
);
|
|
|
|
$io->newLine();
|
|
$io->section(__('Running Database Migrations'));
|
|
|
|
$this->runCommand(
|
|
$output,
|
|
'migrations:migrate',
|
|
[
|
|
'--allow-no-migration' => true,
|
|
]
|
|
);
|
|
|
|
$io->newLine();
|
|
$io->section(__('Generating Database Proxy Classes'));
|
|
|
|
$this->runCommand($output, 'orm:generate-proxies');
|
|
|
|
$io->newLine();
|
|
$io->section(__('Reload System Data'));
|
|
|
|
$this->runCommand($output, 'cache:clear');
|
|
|
|
// Ensure default storage locations exist.
|
|
$this->storageLocationRepo->createDefaultStorageLocations();
|
|
|
|
$io->newLine();
|
|
$io->success(
|
|
[
|
|
__('AzuraCast is now initialized.'),
|
|
]
|
|
);
|
|
|
|
return 0;
|
|
}
|
|
}
|