random improvements (#5506)
* fix order of destroying form elements * API documentation - fixes #1949 * make command path independent * use PhpSubprocess to execute migrations * allow to configure optional SAML attributes * fix deprecation * unify wording of exported state - fixes #5392
This commit is contained in:
@@ -18,6 +18,7 @@ use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symfony\Component\Filesystem\Exception\FileNotFoundException;
|
||||
use Symfony\Component\Process\PhpSubprocess;
|
||||
|
||||
/**
|
||||
* Extend this class if you have a plugin that requires installation steps.
|
||||
@@ -36,8 +37,7 @@ abstract class AbstractBundleInstallerCommand extends Command
|
||||
}
|
||||
|
||||
/**
|
||||
* If your bundle ships assets, that need to be available in the public/ directory,
|
||||
* then overwrite this method and return: <true>.
|
||||
* Return <true> if your bundle ships assets for the public/ directory.
|
||||
*/
|
||||
protected function hasAssets(): bool
|
||||
{
|
||||
@@ -189,13 +189,28 @@ abstract class AbstractBundleInstallerCommand extends Command
|
||||
// prevent windows from breaking
|
||||
$config = str_replace('/', DIRECTORY_SEPARATOR, $config);
|
||||
|
||||
$command = $this->getApplication()->find('doctrine:migrations:migrate');
|
||||
$cmdInput = new ArrayInput(['--allow-no-migration' => true, '--configuration' => $config]);
|
||||
$cmdInput->setInteractive(false);
|
||||
if (0 !== $command->run($cmdInput, $output)) {
|
||||
$process = new PhpSubprocess(
|
||||
[
|
||||
'bin/console',
|
||||
'doctrine:migrations:migrate',
|
||||
'--allow-no-migration',
|
||||
'--no-interaction',
|
||||
'--configuration=' . $config
|
||||
],
|
||||
$this->getRootDirectory()
|
||||
);
|
||||
$process->run();
|
||||
|
||||
if (!$process->isSuccessful()) {
|
||||
$io->error('Failed to install bundle database: ' . PHP_EOL . $config);
|
||||
$io->error($process->getErrorOutput());
|
||||
throw new \Exception('Problem occurred while executing migrations.');
|
||||
}
|
||||
|
||||
if ($io->isVerbose()) {
|
||||
$io->write($process->getOutput());
|
||||
}
|
||||
|
||||
$io->writeln('');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ abstract class AbstractResetCommand extends Command
|
||||
}
|
||||
|
||||
try {
|
||||
$command = $this->getApplication()->find('doctrine:query:sql');
|
||||
$command = $this->getApplication()->find('dbal:run-sql');
|
||||
$command->run(new ArrayInput(['sql' => 'DROP TABLE IF EXISTS migration_versions']), $output);
|
||||
} catch (Exception $ex) {
|
||||
$io->error('Failed to drop migration_versions table: ' . $ex->getMessage());
|
||||
@@ -125,7 +125,7 @@ abstract class AbstractResetCommand extends Command
|
||||
}
|
||||
|
||||
try {
|
||||
$command = $this->getApplication()->find('doctrine:query:sql');
|
||||
$command = $this->getApplication()->find('dbal:run-sql');
|
||||
$command->run(new ArrayInput(['sql' => 'DROP TABLE IF EXISTS kimai2_sessions']), $output);
|
||||
} catch (Exception $ex) {
|
||||
$io->error('Failed to drop kimai2_sessions table: ' . $ex->getMessage());
|
||||
|
||||
@@ -26,7 +26,8 @@ final class PluginCommand extends Command
|
||||
{
|
||||
public function __construct(
|
||||
private readonly PluginManager $pluginManager,
|
||||
private readonly PackageManager $packageManager
|
||||
private readonly PackageManager $packageManager,
|
||||
private readonly string $projectDirectory
|
||||
)
|
||||
{
|
||||
parent::__construct();
|
||||
@@ -69,17 +70,16 @@ final class PluginCommand extends Command
|
||||
}
|
||||
}
|
||||
|
||||
// using getApplication()->find('doctrine:migrations:migrate') does NOT work here
|
||||
// because the Doctrine command can only be executed once
|
||||
// if run more than once it fails with a "Container is frozen" exception
|
||||
|
||||
$process = new PhpSubprocess([
|
||||
'bin/console',
|
||||
'doctrine:migrations:migrate',
|
||||
'--allow-no-migration',
|
||||
'--no-interaction',
|
||||
'--configuration=' . $config
|
||||
]);
|
||||
$process = new PhpSubprocess(
|
||||
[
|
||||
'bin/console',
|
||||
'doctrine:migrations:migrate',
|
||||
'--allow-no-migration',
|
||||
'--no-interaction',
|
||||
'--configuration=' . $config
|
||||
],
|
||||
$this->projectDirectory
|
||||
);
|
||||
$process->run();
|
||||
|
||||
if (!$process->isSuccessful()) {
|
||||
|
||||
@@ -10,9 +10,10 @@
|
||||
namespace App\Command;
|
||||
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symfony\Component\Process\PhpSubprocess;
|
||||
|
||||
/**
|
||||
* Command used to execute all the basic application bootstrapping AFTER "composer install" was executed.
|
||||
@@ -24,16 +25,36 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||
#[AsCommand(name: 'kimai:reset:dev', description: 'Resets the "development" environment')]
|
||||
final class ResetDevelopmentCommand extends AbstractResetCommand
|
||||
{
|
||||
public function __construct(string $kernelEnvironment)
|
||||
public function __construct(string $kernelEnvironment, private readonly string $projectDirectory)
|
||||
{
|
||||
parent::__construct($kernelEnvironment);
|
||||
}
|
||||
|
||||
protected function loadData(InputInterface $input, OutputInterface $output): void
|
||||
{
|
||||
$command = $this->getApplication()->find('doctrine:fixtures:load');
|
||||
$cmdInput = new ArrayInput([]);
|
||||
$cmdInput->setInteractive(false);
|
||||
$command->run($cmdInput, $output);
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
|
||||
$io->writeln('Importing fixtures, this will take a while ... please be patient ...');
|
||||
|
||||
$process = new PhpSubprocess(
|
||||
[
|
||||
'bin/console',
|
||||
'doctrine:fixtures:load',
|
||||
'--no-interaction',
|
||||
],
|
||||
$this->projectDirectory
|
||||
);
|
||||
$process->run();
|
||||
|
||||
if (!$process->isSuccessful()) {
|
||||
$io->error('Failed to load fixtures');
|
||||
$io->error($process->getErrorOutput());
|
||||
} else {
|
||||
if ($io->isVerbose()) {
|
||||
$io->write($process->getOutput());
|
||||
} else {
|
||||
$io->success('Fixtures loaded');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user