Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TASK] Migrate configuration commands #1111

Merged
merged 1 commit into from Feb 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -25,9 +25,19 @@

class ConfigurationRemoveCommand extends Command
{
public function __construct(private readonly bool $applicationIsReady)
{
parent::__construct('configuration:remove');
}

public function isEnabled(): bool
{
return $this->applicationIsReady || getenv('TYPO3_CONSOLE_RENDERING_REFERENCE') !== false;
}

protected function configure()
{
$this->setDescription('Remove configuration option');
$this->setDescription('Remove configuration value');
$this->setHelp(
<<<'EOH'
Removes a system configuration option by path.
Expand Down
10 changes: 10 additions & 0 deletions Classes/Console/Command/Configuration/ConfigurationSetCommand.php
Expand Up @@ -23,6 +23,16 @@

class ConfigurationSetCommand extends Command
{
public function __construct(private readonly bool $applicationIsReady)
{
parent::__construct('configuration:set');
}

public function isEnabled(): bool
{
return $this->applicationIsReady || getenv('TYPO3_CONSOLE_RENDERING_REFERENCE') !== false;
}

protected function configure()
{
$this->setDescription('Set configuration value');
Expand Down
Expand Up @@ -25,6 +25,16 @@

class ConfigurationShowLocalCommand extends Command implements RelatableCommandInterface
{
public function __construct(private readonly bool $applicationIsReady)
{
parent::__construct('configuration:showlocal');
}

public function isEnabled(): bool
{
return $this->applicationIsReady || getenv('TYPO3_CONSOLE_RENDERING_REFERENCE') !== false;
}

public function getRelatedCommandNames(): array
{
return [
Expand Down
33 changes: 32 additions & 1 deletion Classes/Console/ServiceProvider.php
Expand Up @@ -2,6 +2,9 @@
declare(strict_types=1);
namespace Helhum\Typo3Console;

use Helhum\Typo3Console\Command\Configuration\ConfigurationRemoveCommand;
use Helhum\Typo3Console\Command\Configuration\ConfigurationSetCommand;
use Helhum\Typo3Console\Command\Configuration\ConfigurationShowLocalCommand;
use Helhum\Typo3Console\Command\Database\DatabaseUpdateSchemaCommand;
use Helhum\Typo3Console\Command\Install\InstallActionNeedsExecutionCommand;
use Helhum\Typo3Console\Command\Install\InstallDatabaseConnectCommand;
Expand All @@ -15,8 +18,10 @@
use Helhum\Typo3Console\Command\InstallTool\LockInstallToolCommand;
use Helhum\Typo3Console\Command\InstallTool\UnlockInstallToolCommand;
use Psr\Container\ContainerInterface;
use TYPO3\CMS\Core\Configuration\ConfigurationManager;
use TYPO3\CMS\Core\Console\CommandRegistry;
use TYPO3\CMS\Core\Core\BootService;
use TYPO3\CMS\Core\Core\Bootstrap;
use TYPO3\CMS\Core\Package\AbstractServiceProvider;

class ServiceProvider extends AbstractServiceProvider
Expand All @@ -29,6 +34,9 @@ protected static function getPackagePath(): string
public function getFactories(): array
{
return [
ConfigurationRemoveCommand::class => [ static::class, 'getConfigurationRemoveCommand' ],
ConfigurationSetCommand::class => [ static::class, 'getConfigurationSetCommand' ],
ConfigurationShowLocalCommand::class => [ static::class, 'getConfigurationShowLocalCommand' ],
DatabaseUpdateSchemaCommand::class => [ static::class, 'getDatabaseUpdateSchemaCommand' ],
InstallSetupCommand::class => [ static::class, 'getInstallSetupCommand' ],
InstallFixFolderStructureCommand::class => [ static::class, 'getInstallFixFolderStructureCommand' ],
Expand All @@ -51,6 +59,21 @@ public function getExtensions(): array
] + parent::getExtensions();
}

public static function getConfigurationRemoveCommand(ContainerInterface $container): ConfigurationRemoveCommand
{
return new ConfigurationRemoveCommand(self::applicationIsReady($container));
}

public static function getConfigurationSetCommand(ContainerInterface $container): ConfigurationSetCommand
{
return new ConfigurationSetCommand(self::applicationIsReady($container));
}

public static function getConfigurationShowLocalCommand(ContainerInterface $container): ConfigurationShowLocalCommand
{
return new ConfigurationShowLocalCommand(self::applicationIsReady($container));
}

public static function getDatabaseUpdateSchemaCommand(ContainerInterface $container): DatabaseUpdateSchemaCommand
{
return new DatabaseUpdateSchemaCommand($container->get(BootService::class));
Expand Down Expand Up @@ -113,6 +136,9 @@ public static function getUnlockInstallToolCommand(): UnlockInstallToolCommand

public static function configureCommands(ContainerInterface $container, CommandRegistry $commandRegistry): CommandRegistry
{
$commandRegistry->addLazyCommand('configuration:remove', ConfigurationRemoveCommand::class, 'Remove configuration value');
$commandRegistry->addLazyCommand('configuration:set', ConfigurationSetCommand::class, 'Set configuration value');
$commandRegistry->addLazyCommand('configuration:showlocal', ConfigurationShowLocalCommand::class, 'Show local configuration value');
$commandRegistry->addLazyCommand('database:updateschema', DatabaseUpdateSchemaCommand::class, 'Update database schema (TYPO3 Database Compare)');
$commandRegistry->addLazyCommand('install:setup', InstallSetupCommand::class, 'TYPO3 Setup');
$commandRegistry->addLazyCommand('install:fixfolderstructure', InstallFixFolderStructureCommand::class, 'Fix folder structure');
Expand All @@ -121,11 +147,16 @@ public static function configureCommands(ContainerInterface $container, CommandR
$commandRegistry->addLazyCommand('install:databaseconnect', InstallDatabaseConnectCommand::class, 'Connect to database');
$commandRegistry->addLazyCommand('install:databasedata', InstallDatabaseDataCommand::class, 'Add database data');
$commandRegistry->addLazyCommand('install:databaseselect', InstallDatabaseSelectCommand::class, 'Select database');
$commandRegistry->addLazyCommand('install:defaultconfiguration', InstallDefaultConfigurationCommand::class, 'Select database');
$commandRegistry->addLazyCommand('install:defaultconfiguration', InstallDefaultConfigurationCommand::class, 'Write default configuration');
$commandRegistry->addLazyCommand('install:actionneedsexecution', InstallActionNeedsExecutionCommand::class, 'Calls needs execution on the given action and returns the result');
$commandRegistry->addLazyCommand('install:lock', LockInstallToolCommand::class, 'Lock Install Tool');
$commandRegistry->addLazyCommand('install:unlock', UnlockInstallToolCommand::class, 'Unlock Install Tool');

return $commandRegistry;
}

private static function applicationIsReady(ContainerInterface $container): bool
{
return Bootstrap::checkIfEssentialConfigurationExists($container->get(ConfigurationManager::class));
}
}
15 changes: 0 additions & 15 deletions Configuration/Commands.php
Expand Up @@ -2,21 +2,6 @@
declare(strict_types=1);

return [
'configuration:remove' => [
'vendor' => 'typo3_console',
'class' => \Helhum\Typo3Console\Command\Configuration\ConfigurationRemoveCommand::class,
'runLevel' => \Helhum\Typo3Console\Core\Booting\RunLevel::LEVEL_MINIMAL,
],
'configuration:set' => [
'vendor' => 'typo3_console',
'class' => \Helhum\Typo3Console\Command\Configuration\ConfigurationSetCommand::class,
'runLevel' => \Helhum\Typo3Console\Core\Booting\RunLevel::LEVEL_MINIMAL,
],
'configuration:showlocal' => [
'vendor' => 'typo3_console',
'class' => \Helhum\Typo3Console\Command\Configuration\ConfigurationShowLocalCommand::class,
'runLevel' => \Helhum\Typo3Console\Core\Booting\RunLevel::LEVEL_MINIMAL,
],
'database:export' => [
'vendor' => 'typo3_console',
'class' => \Helhum\Typo3Console\Command\Database\DatabaseExportCommand::class,
Expand Down
2 changes: 1 addition & 1 deletion Documentation/CommandReference/ConfigurationRemove.rst
Expand Up @@ -11,7 +11,7 @@ configuration:remove
====================


**Remove configuration option**
**Remove configuration value**

Removes a system configuration option by path.

Expand Down