Skip to content

Commit

Permalink
Merge pull request #848 from helhum/related-commands
Browse files Browse the repository at this point in the history
[TASK] Properly implement related commands for SF commands
  • Loading branch information
mbrodala committed Oct 7, 2019
2 parents 6e59a71 + aa13b46 commit c76c7be
Show file tree
Hide file tree
Showing 17 changed files with 140 additions and 106 deletions.
10 changes: 9 additions & 1 deletion Classes/Console/Command/Backend/LockBackendCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,22 @@
*
*/

use Helhum\Typo3Console\Command\RelatableCommandInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;

class LockBackendCommand extends Command
class LockBackendCommand extends Command implements RelatableCommandInterface
{
public function getRelatedCommandNames(): array
{
return [
'typo3_console:backend:unlock',
];
}

protected function configure()
{
$this->setDescription('Lock backend');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,24 @@
*
*/

use Helhum\Typo3Console\Command\RelatableCommandInterface;
use Helhum\Typo3Console\Service\Configuration\ConfigurationService;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class LockBackendForEditorsCommand extends Command
class LockBackendForEditorsCommand extends Command implements RelatableCommandInterface
{
private static $LOCK_TYPE_UNLOCKED = 0;
private static $LOCK_TYPE_ADMIN = 2;

public function getRelatedCommandNames(): array
{
return [
'typo3_console:backend:unlockforeditors',
];
}

protected function configure()
{
$this->setDescription('Lock backend for editors');
Expand Down
10 changes: 9 additions & 1 deletion Classes/Console/Command/Backend/UnlockBackendCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,20 @@
*
*/

use Helhum\Typo3Console\Command\RelatableCommandInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class UnlockBackendCommand extends Command
class UnlockBackendCommand extends Command implements RelatableCommandInterface
{
public function getRelatedCommandNames(): array
{
return [
'typo3_console:backend:lock',
];
}

protected function configure()
{
$this->setDescription('Unlock backend');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,23 @@
*
*/

use Helhum\Typo3Console\Command\RelatableCommandInterface;
use Helhum\Typo3Console\Service\Configuration\ConfigurationService;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class UnlockBackendForEditorsCommand extends Command
class UnlockBackendForEditorsCommand extends Command implements RelatableCommandInterface
{
private static $LOCK_TYPE_UNLOCKED = 0;

public function getRelatedCommandNames(): array
{
return [
'typo3_console:backend:lockforeditors',
];
}

protected function configure()
{
$this->setDescription('Unlock backend for editors');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*
*/

use Helhum\Typo3Console\Command\RelatableCommandInterface;
use Helhum\Typo3Console\Service\Configuration\ConfigurationService;
use Helhum\Typo3Console\Service\Configuration\ConsoleRenderer\ConsoleRenderer;
use Symfony\Component\Console\Command\Command;
Expand All @@ -22,8 +23,15 @@
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class ConfigurationShowLocalCommand extends Command
class ConfigurationShowLocalCommand extends Command implements RelatableCommandInterface
{
public function getRelatedCommandNames(): array
{
return [
'typo3_console:configuration:show',
];
}

protected function configure()
{
$this->setDescription('Show local configuration value');
Expand All @@ -34,16 +42,6 @@ protected function configure()
Note that this value could be overridden. Use <code>typo3cms configuration:show <path></code> to see if this is the case.
<b>Example:</b> <code>%command.full_name% DB</code>
Related commands
~~~~~~~~~~~~~~~~
`configuration:show`
Show configuration value
EOH
);
$this->addArgument(
Expand Down
2 changes: 1 addition & 1 deletion Classes/Console/Command/Database/DatabaseExportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ protected function createNativeDefinition(): array
'exclude',
'-e',
InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
'Full table name or wildcard expression to exclude from the export',
'Full table name or wildcard expression to exclude from the export.',
[]
),
new InputOption(
Expand Down
2 changes: 1 addition & 1 deletion Classes/Console/Command/Database/DatabaseImportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected function configure()
'interactive',
null,
InputOption::VALUE_NONE,
'Open an interactive mysql shell using the TYPO3 connection settings'
'Open an interactive mysql shell using the TYPO3 connection settings.'
);
$this->addOption(
'connection',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected function configure()
$this->addArgument(
'extensionKeys',
InputArgument::REQUIRED,
'Extension keys to activate. Separate multiple extension keys with comma'
'Extension keys to activate. Separate multiple extension keys with comma.'
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected function configure()
$this->addArgument(
'extensionKeys',
InputArgument::REQUIRED,
'Extension keys to deactivate. Separate multiple extension keys with comma'
'Extension keys to deactivate. Separate multiple extension keys with comma.'
);
}

Expand Down
24 changes: 11 additions & 13 deletions Classes/Console/Command/Extension/ExtensionSetupActiveCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,22 @@
*
*/

use Helhum\Typo3Console\Command\RelatableCommandInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class ExtensionSetupActiveCommand extends Command
class ExtensionSetupActiveCommand extends Command implements RelatableCommandInterface
{
public function getRelatedCommandNames(): array
{
return [
'typo3_console:extension:setup',
'typo3_console:install:generatepackagestates',
'typo3_console:cache:flush',
];
}

protected function configure()
{
$this->setDescription('Set up all active extensions');
Expand All @@ -32,18 +42,6 @@ protected function configure()
setup step for the (changed) extensions is performed.
As an additional benefit no caches are flushed, which significantly improves performance of this command
and avoids unnecessary cache clearing.
Related commands
~~~~~~~~~~~~~~~~
`extension:setup`
Set up extension(s)
`install:generatepackagestates`
Generate PackageStates.php file
`cache:flush`
Flush all caches
EOH
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected function configure()
$this->addArgument(
'extensionKeys',
InputArgument::REQUIRED,
'Extension keys to set up. Separate multiple extension keys with comma'
'Extension keys to set up. Separate multiple extension keys with comma.'
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,20 @@
*
*/

use Helhum\Typo3Console\Command\RelatableCommandInterface;
use Helhum\Typo3Console\Mvc\Cli\CommandDispatcher;
use Helhum\Typo3Console\Mvc\Cli\FailedSubProcessCommandException;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use TYPO3\CMS\Core\Package\PackageManager;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;

class InstallExtensionSetupIfPossibleCommand extends Command
class InstallExtensionSetupIfPossibleCommand extends Command implements RelatableCommandInterface
{
/**
* @var PackageManager
*/
protected $packageManager;

public function __construct(string $name = null, PackageManager $packageManager = null)
public function getRelatedCommandNames(): array
{
parent::__construct($name);

$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$this->packageManager = $packageManager ?? $objectManager->get(PackageManager::class);
return [
'typo3_console:extension:setupactive',
];
}

protected function configure()
Expand All @@ -50,14 +42,6 @@ protected function configure()
Besides that, it can be used for a first deploy of a TYPO3 instance in a new environment,
but also works for subsequent deployments.
Related commands
~~~~~~~~~~~~~~~~
`extension:setupactive`
Set up all active extensions
EOH
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,21 @@
*
*/

use Helhum\Typo3Console\Command\RelatableCommandInterface;
use Helhum\Typo3Console\Install\FolderStructure\ExtensionFactory;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use TYPO3\CMS\Core\Package\PackageManager;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;

class InstallFixFolderStructureCommand extends Command
class InstallFixFolderStructureCommand extends Command implements RelatableCommandInterface
{
/**
* @var PackageManager
*/
protected $packageManager;

public function __construct(string $name = null, PackageManager $packageManager = null)
public function getRelatedCommandNames(): array
{
parent::__construct($name);

$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$this->packageManager = $packageManager ?? $objectManager->get(PackageManager::class);
return [
'typo3_console:install:generatepackagestates',
];
}

protected function configure()
Expand All @@ -48,14 +42,6 @@ protected function configure()
It is recommended to be executed <b>after</b> executing
<code>typo3cms install:generatepackagestates</code>, to ensure proper generation of
required folders for all active extensions.
Related commands
~~~~~~~~~~~~~~~~
`install:generatepackagestates`
Generate PackageStates.php file
EOH
);
}
Expand All @@ -68,7 +54,7 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$folderStructureFactory = new ExtensionFactory($this->packageManager);
$folderStructureFactory = new ExtensionFactory(GeneralUtility::makeInstance(PackageManager::class));
$fixedStatusObjects = $folderStructureFactory
->getStructure()
->fix();
Expand Down
20 changes: 20 additions & 0 deletions Classes/Console/Command/RelatableCommandInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
declare(strict_types=1);
namespace Helhum\Typo3Console\Command;

/*
* This file is part of the TYPO3 Console project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read
* LICENSE file that was distributed with this source code.
*
*/

interface RelatableCommandInterface
{
public function getRelatedCommandNames(): array;
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
* The TYPO3 project - inspiring people to share!
*/

use Helhum\Typo3Console\Command\RelatableCommandInterface;
use Helhum\Typo3Console\Mvc\Cli\Command as CommandDefinition;
use Helhum\Typo3Console\Mvc\Cli\RequestHandler;
use Helhum\Typo3Console\Mvc\Cli\Symfony\Application;
Expand All @@ -41,7 +42,7 @@
/**
* Wrapper to turn a command controller commands into a Symfony Command
*/
class CommandControllerCommand extends Command
class CommandControllerCommand extends Command implements RelatableCommandInterface
{
/**
* @var CommandDefinition
Expand Down Expand Up @@ -81,7 +82,7 @@ public function getNativeDefinition()
return $commandInputDefinition;
}

public function getRelatedCommandNames()
public function getRelatedCommandNames(): array
{
return $this->commandDefinition->getRelatedCommandIdentifiers();
}
Expand Down
Loading

0 comments on commit c76c7be

Please sign in to comment.