first commit
This commit is contained in:
commit
1218dd1517
12716 files changed
+989233
No files matched your search
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
namespace TYPO3\CMS\Extbase\Command;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS 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 the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use TYPO3\CMS\Core\Package\FailsafePackageManager;
|
||||
use TYPO3\CMS\Core\Package\PackageManager;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Core\Bootstrap;
|
||||
use TYPO3\CMS\Extbase\Mvc\Cli\CommandManager;
|
||||
use TYPO3\CMS\Extbase\Object\ObjectManager;
|
||||
|
||||
/**
|
||||
* Main call to register any Extbase command from Extbase command controllers
|
||||
*
|
||||
* Fetches all registered Extbase commands and adds them to the application as custom Extbase commands
|
||||
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10.0. Use symfony/console commands instead.
|
||||
*/
|
||||
class CoreCommand extends Command
|
||||
{
|
||||
/**
|
||||
* @var Bootstrap
|
||||
*/
|
||||
protected $extbaseBootstrap;
|
||||
|
||||
/**
|
||||
* Configure the command, since this is a command
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setHidden(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the application instance for this command.
|
||||
* This is done in setApplication() because configure() is called too early to do it in that place.
|
||||
* The method 'setApplication()' is done right afterwards but has the application object to call.
|
||||
* Then registers additional commands that act as wrappers to the actual Extbase commands.
|
||||
*
|
||||
* @param Application $application An Application instance
|
||||
*/
|
||||
public function setApplication(Application $application = null)
|
||||
{
|
||||
parent::setApplication($application);
|
||||
|
||||
// Extbase commands can not be initialized in failsafe mode
|
||||
if (GeneralUtility::makeInstance(PackageManager::class) instanceof FailsafePackageManager) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Find any registered Extbase commands
|
||||
$this->extbaseBootstrap = GeneralUtility::makeInstance(Bootstrap::class);
|
||||
$this->extbaseBootstrap->initialize([]);
|
||||
|
||||
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
|
||||
|
||||
/** @var CommandManager $commandManager */
|
||||
$commandManager = $objectManager->get(CommandManager::class);
|
||||
$commands = $commandManager->getAvailableCommands();
|
||||
foreach ($commands as $command) {
|
||||
$commandName = $commandManager->getShortestIdentifierForCommand($command);
|
||||
$fullCommandName = $command->getCommandIdentifier();
|
||||
if ($fullCommandName === 'extbase:help:error' || $fullCommandName === 'extbase:help:helpstub') {
|
||||
continue;
|
||||
}
|
||||
if ($commandName === 'help') {
|
||||
$commandName = 'extbase:help';
|
||||
}
|
||||
$extbaseCommand = GeneralUtility::makeInstance(ExtbaseCommand::class, $fullCommandName);
|
||||
|
||||
if ($commandName !== $fullCommandName) {
|
||||
$extbaseCommand->setAliases([$commandName]);
|
||||
}
|
||||
|
||||
$extbaseCommand->setExtbaseCommand($command);
|
||||
$this->getApplication()->add($extbaseCommand);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
namespace TYPO3\CMS\Extbase\Command;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS 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 the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Core\Bootstrap;
|
||||
|
||||
/**
|
||||
* Wrapper to wrap an Extbase command from a command controller into a Symfony Command
|
||||
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10.0. Use symfony/console commands instead.
|
||||
*/
|
||||
class ExtbaseCommand extends Command
|
||||
{
|
||||
/**
|
||||
* Extbase's command
|
||||
* @var \TYPO3\CMS\Extbase\Mvc\Cli\Command
|
||||
*/
|
||||
protected $command;
|
||||
|
||||
/**
|
||||
* Extbase has its own validation logic, so it is disabled in this place
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->ignoreValidationErrors();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the extbase command to be used for fetching the description etc.
|
||||
*
|
||||
* @param \TYPO3\CMS\Extbase\Mvc\Cli\Command $command
|
||||
*/
|
||||
public function setExtbaseCommand(\TYPO3\CMS\Extbase\Mvc\Cli\Command $command)
|
||||
{
|
||||
$this->command = $command;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the application instance for this command.
|
||||
* Also uses the setApplication call now, as $this->configure() is called
|
||||
* too early
|
||||
*
|
||||
* @param Application $application An Application instance
|
||||
*/
|
||||
public function setApplication(Application $application = null)
|
||||
{
|
||||
parent::setApplication($application);
|
||||
$description = $this->command->getDescription();
|
||||
$description = str_replace(LF, ' ', $description);
|
||||
$this->setDescription($description);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the command to find any Extbase command
|
||||
*
|
||||
* @param InputInterface $input
|
||||
* @param OutputInterface $output
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
// ugly hack because extbase only knows "help" (hardcoded, but already defined by symfony)
|
||||
// and "extbase:help:help"
|
||||
if ($_SERVER['argv'][1] === 'extbase:help') {
|
||||
$_SERVER['argv'][1] = 'extbase:help:help';
|
||||
}
|
||||
$bootstrap = GeneralUtility::makeInstance(Bootstrap::class);
|
||||
$bootstrap->run('', []);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
namespace TYPO3\CMS\Extbase\Command;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS 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 the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Core\Bootstrap;
|
||||
|
||||
/**
|
||||
* Extends the help command of symfony to show the specific help for Extbase commands
|
||||
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10.0. Use symfony/console commands instead.
|
||||
*/
|
||||
class HelpCommand extends \Symfony\Component\Console\Command\HelpCommand
|
||||
{
|
||||
/**
|
||||
* This needs to be re-set as the parent command has this property declared as "private" as well.
|
||||
*
|
||||
* @var Command
|
||||
*/
|
||||
private $command;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
parent::configure();
|
||||
$this->setAliases([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
if (null === $this->command) {
|
||||
$this->command = $this->getApplication()->find($input->getArgument('command_name'));
|
||||
}
|
||||
|
||||
// Extbase help was explicitly called
|
||||
if ($input->getArgument('command') === 'extbase:help' || $input->getArgument('command') === 'extbase:help:help') {
|
||||
$_SERVER['argv'][1] = 'extbase:help:help';
|
||||
$bootstrap = GeneralUtility::makeInstance(Bootstrap::class);
|
||||
$bootstrap->run('', []);
|
||||
} elseif ($this->command instanceof ExtbaseCommand) {
|
||||
// An extbase command was originally called, but is now required to show the help information
|
||||
// Ugly hack to modify 'argv' so the help command for a specific command is shown
|
||||
$args = [$_SERVER['argv'][0], 'help'];
|
||||
foreach ($_SERVER['argv'] as $k => $value) {
|
||||
if ($k === 0 || $value === '--help' || $value === '-h') {
|
||||
continue;
|
||||
}
|
||||
$args[] = $value;
|
||||
}
|
||||
$_SERVER['argv'] = $args;
|
||||
|
||||
// run Extbase bootstrap
|
||||
$bootstrap = GeneralUtility::makeInstance(Bootstrap::class);
|
||||
$bootstrap->run('', []);
|
||||
} else {
|
||||
// Any other symfony command should just show up the regular info
|
||||
parent::execute($input, $output);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,220 @@
|
||||
<?php
|
||||
namespace TYPO3\CMS\Extbase\Command;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS 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 the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
/**
|
||||
* A Command Controller which provides help for available commands
|
||||
*
|
||||
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10.0.
|
||||
*/
|
||||
class HelpCommandController extends \TYPO3\CMS\Extbase\Mvc\Controller\CommandController
|
||||
{
|
||||
/**
|
||||
* @var \TYPO3\CMS\Extbase\Mvc\Cli\CommandManager
|
||||
*/
|
||||
protected $commandManager;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $commandsByExtensionsAndControllers = [];
|
||||
|
||||
/**
|
||||
* @param \TYPO3\CMS\Extbase\Mvc\Cli\CommandManager $commandManager
|
||||
*/
|
||||
public function injectCommandManager(\TYPO3\CMS\Extbase\Mvc\Cli\CommandManager $commandManager)
|
||||
{
|
||||
$this->commandManager = $commandManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a short, general help message
|
||||
*
|
||||
* This only outputs the Extbase version number, context and some hint about how to
|
||||
* get more help about commands.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function helpStubCommand()
|
||||
{
|
||||
$this->outputLine('Extbase %s', [TYPO3_version]);
|
||||
$this->outputLine('usage: ' . $this->request->getCallingScript() . ' <command identifier>');
|
||||
$this->outputLine();
|
||||
$this->outputLine('See \'' . $this->request->getCallingScript() . ' help\' for a list of all available commands.');
|
||||
$this->outputLine();
|
||||
}
|
||||
|
||||
/**
|
||||
* Display help for a command
|
||||
*
|
||||
* The help command displays help for a given command:
|
||||
* ./typo3/sysext/core/bin/typo3 extbase:help <command identifier>
|
||||
*
|
||||
* @param string $commandIdentifier Identifier of a command for more details
|
||||
*/
|
||||
public function helpCommand($commandIdentifier = null)
|
||||
{
|
||||
if ($commandIdentifier === null) {
|
||||
$this->displayHelpIndex();
|
||||
} else {
|
||||
try {
|
||||
$command = $this->commandManager->getCommandByIdentifier($commandIdentifier);
|
||||
} catch (\TYPO3\CMS\Extbase\Mvc\Exception\CommandException $exception) {
|
||||
$this->outputLine($exception->getMessage());
|
||||
return;
|
||||
}
|
||||
$this->displayHelpForCommand($command);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds an index of all commands that are available
|
||||
*/
|
||||
protected function displayHelpIndex()
|
||||
{
|
||||
$this->buildCommandsIndex();
|
||||
$this->outputLine('Extbase %s', [TYPO3_version]);
|
||||
$this->outputLine('usage: ' . $this->request->getCallingScript() . ' <command identifier>');
|
||||
$this->outputLine();
|
||||
$this->outputLine('The following commands are currently available:');
|
||||
foreach ($this->commandsByExtensionsAndControllers as $extensionKey => $commandControllers) {
|
||||
$this->outputLine('');
|
||||
$this->outputLine('EXTENSION "%s":', [strtoupper($extensionKey)]);
|
||||
$this->outputLine(str_repeat('-', $this->output->getMaximumLineLength()));
|
||||
foreach ($commandControllers as $commands) {
|
||||
foreach ($commands as $command) {
|
||||
$description = wordwrap($command->getShortDescription(), $this->output->getMaximumLineLength() - 43, PHP_EOL . str_repeat(' ', 43), true);
|
||||
$shortCommandIdentifier = $this->commandManager->getShortestIdentifierForCommand($command);
|
||||
$this->outputLine('%-2s%-40s %s', [' ', $shortCommandIdentifier, $description]);
|
||||
}
|
||||
$this->outputLine();
|
||||
}
|
||||
}
|
||||
$this->outputLine('See \'' . $this->request->getCallingScript() . ' help <command identifier>\' for more information about a specific command.');
|
||||
$this->outputLine();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render help text for a single command
|
||||
*
|
||||
* @param \TYPO3\CMS\Extbase\Mvc\Cli\Command $command
|
||||
*/
|
||||
protected function displayHelpForCommand(\TYPO3\CMS\Extbase\Mvc\Cli\Command $command)
|
||||
{
|
||||
$this->outputLine();
|
||||
$this->outputLine($command->getShortDescription());
|
||||
$this->outputLine();
|
||||
$this->outputLine('COMMAND:');
|
||||
$this->outputLine('%-2s%s', [' ', $command->getCommandIdentifier()]);
|
||||
$commandArgumentDefinitions = $command->getArgumentDefinitions();
|
||||
$usage = '';
|
||||
$hasOptions = false;
|
||||
foreach ($commandArgumentDefinitions as $commandArgumentDefinition) {
|
||||
if (!$commandArgumentDefinition->isRequired()) {
|
||||
$hasOptions = true;
|
||||
} else {
|
||||
$usage .= sprintf(' <%s>', strtolower(preg_replace('/([A-Z])/', ' $1', $commandArgumentDefinition->getName())));
|
||||
}
|
||||
}
|
||||
$usage = $this->request->getCallingScript() . ' ' . $this->commandManager->getShortestIdentifierForCommand($command) . ($hasOptions ? ' [<options>]' : '') . $usage;
|
||||
$this->outputLine();
|
||||
$this->outputLine('USAGE:');
|
||||
$this->outputLine(' ' . $usage);
|
||||
$argumentDescriptions = [];
|
||||
$optionDescriptions = [];
|
||||
if ($command->hasArguments()) {
|
||||
foreach ($commandArgumentDefinitions as $commandArgumentDefinition) {
|
||||
$argumentDescription = $commandArgumentDefinition->getDescription();
|
||||
$argumentDescription = wordwrap($argumentDescription, $this->output->getMaximumLineLength() - 23, PHP_EOL . str_repeat(' ', 23), true);
|
||||
if ($commandArgumentDefinition->isRequired()) {
|
||||
$argumentDescriptions[] = vsprintf(' %-20s %s', [$commandArgumentDefinition->getDashedName(), $argumentDescription]);
|
||||
} else {
|
||||
$optionDescriptions[] = vsprintf(' %-20s %s', [$commandArgumentDefinition->getDashedName(), $argumentDescription]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($argumentDescriptions)) {
|
||||
$this->outputLine();
|
||||
$this->outputLine('ARGUMENTS:');
|
||||
foreach ($argumentDescriptions as $argumentDescription) {
|
||||
$this->outputLine($argumentDescription);
|
||||
}
|
||||
}
|
||||
if (!empty($optionDescriptions)) {
|
||||
$this->outputLine();
|
||||
$this->outputLine('OPTIONS:');
|
||||
foreach ($optionDescriptions as $optionDescription) {
|
||||
$this->outputLine($optionDescription);
|
||||
}
|
||||
}
|
||||
if ($command->getDescription() !== '') {
|
||||
$this->outputLine();
|
||||
$this->outputLine('DESCRIPTION:');
|
||||
$descriptionLines = explode(LF, $command->getDescription());
|
||||
foreach ($descriptionLines as $descriptionLine) {
|
||||
$this->outputLine('%-2s%s', [' ', $descriptionLine]);
|
||||
}
|
||||
}
|
||||
$relatedCommandIdentifiers = $command->getRelatedCommandIdentifiers();
|
||||
if ($relatedCommandIdentifiers !== []) {
|
||||
$this->outputLine();
|
||||
$this->outputLine('SEE ALSO:');
|
||||
foreach ($relatedCommandIdentifiers as $commandIdentifier) {
|
||||
$command = $this->commandManager->getCommandByIdentifier($commandIdentifier);
|
||||
$this->outputLine('%-2s%s (%s)', [' ', $commandIdentifier, $command->getShortDescription()]);
|
||||
}
|
||||
}
|
||||
$this->outputLine();
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays an error message
|
||||
*
|
||||
* @internal
|
||||
* @param \TYPO3\CMS\Extbase\Mvc\Exception\CommandException $exception
|
||||
*/
|
||||
public function errorCommand(\TYPO3\CMS\Extbase\Mvc\Exception\CommandException $exception)
|
||||
{
|
||||
$this->outputLine($exception->getMessage());
|
||||
if ($exception instanceof \TYPO3\CMS\Extbase\Mvc\Exception\AmbiguousCommandIdentifierException) {
|
||||
$this->outputLine('Please specify the complete command identifier. Matched commands:');
|
||||
foreach ($exception->getMatchingCommands() as $matchingCommand) {
|
||||
$this->outputLine(' %s', [$matchingCommand->getCommandIdentifier()]);
|
||||
}
|
||||
}
|
||||
$this->outputLine('');
|
||||
$this->outputLine('Enter "' . $this->request->getCallingScript() . ' help" for an overview of all available commands');
|
||||
$this->outputLine('or "' . $this->request->getCallingScript() . ' help <command identifier>" for a detailed description of the corresponding command.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds an index of available commands. For each of them a Command object is
|
||||
* added to the commands array of this class.
|
||||
*/
|
||||
protected function buildCommandsIndex()
|
||||
{
|
||||
$availableCommands = $this->commandManager->getAvailableCommands();
|
||||
foreach ($availableCommands as $command) {
|
||||
if ($command->isInternal()) {
|
||||
continue;
|
||||
}
|
||||
$commandIdentifier = $command->getCommandIdentifier();
|
||||
$extensionKey = strstr($commandIdentifier, ':', true);
|
||||
$commandControllerClassName = $command->getControllerClassName();
|
||||
$commandName = $command->getControllerCommandName();
|
||||
$this->commandsByExtensionsAndControllers[$extensionKey][$commandControllerClassName][$commandName] = $command;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user