[!!!][TASK] Update Symfony Console to version 3.x 05/46505/7
authorMathias Brodala <mbrodala@pagemachine.de>
Fri, 5 Feb 2016 16:41:38 +0000 (17:41 +0100)
committerBenni Mack <benni@typo3.org>
Fri, 12 Feb 2016 06:26:08 +0000 (07:26 +0100)
This migrates the Extbase ConsoleOutput wrapper to the newer API.

Change-Id: If26fc4f783c1c66bfd7818ea2aedd9055bcbdf92
Resolves: #73152
Releases: master
Reviewed-on: https://review.typo3.org/46505
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
Reviewed-by: Daniel Goerz <ervaude@gmail.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
composer.json
composer.lock
typo3/sysext/core/Documentation/Changelog/master/Breaking-73152-SymfonyConsoleHelpersReplaced.rst [new file with mode: 0644]
typo3/sysext/extbase/Classes/Mvc/Cli/ConsoleOutput.php

index 20fd968..37f5406 100644 (file)
@@ -39,7 +39,7 @@
                "psr/log": "1.0.*@dev",
                "pear/http_request2": "~2.2.1",
                "swiftmailer/swiftmailer": "~5.4.1",
-               "symfony/console": "~2.7.0",
+               "symfony/console": "^3.0",
                "symfony/finder": "^3.0",
                "doctrine/instantiator": "~1.0.4",
                "typo3/class-alias-loader": "^1.0",
index ce58700..982fb8f 100644 (file)
@@ -4,8 +4,8 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
         "This file is @generated automatically"
     ],
-    "hash": "62e45845183e26c37ccbd099b037f99e",
-    "content-hash": "3b132470e65d3d3c549acfe5589924ec",
+    "hash": "842c868f3c68b97f7c6a1484c39d5cbb",
+    "content-hash": "f87893bc1c9657e4f83e863a23ce102b",
     "packages": [
         {
             "name": "cogpowered/finediff",
         },
         {
             "name": "symfony/console",
-            "version": "v2.7.4",
+            "version": "v3.0.2",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/console.git",
-                "reference": "9ff9032151186bd66ecee727d728f1319f52d1d8"
+                "reference": "5a02eaadaa285e2bb727eb6bbdfb8201fcd971b0"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/console/zipball/9ff9032151186bd66ecee727d728f1319f52d1d8",
-                "reference": "9ff9032151186bd66ecee727d728f1319f52d1d8",
+                "url": "https://api.github.com/repos/symfony/console/zipball/5a02eaadaa285e2bb727eb6bbdfb8201fcd971b0",
+                "reference": "5a02eaadaa285e2bb727eb6bbdfb8201fcd971b0",
                 "shasum": ""
             },
             "require": {
-                "php": ">=5.3.9"
+                "php": ">=5.5.9",
+                "symfony/polyfill-mbstring": "~1.0"
             },
             "require-dev": {
                 "psr/log": "~1.0",
-                "symfony/event-dispatcher": "~2.1",
-                "symfony/phpunit-bridge": "~2.7",
-                "symfony/process": "~2.1"
+                "symfony/event-dispatcher": "~2.8|~3.0",
+                "symfony/process": "~2.8|~3.0"
             },
             "suggest": {
                 "psr/log": "For using the console logger",
             "type": "library",
             "extra": {
                 "branch-alias": {
-                    "dev-master": "2.7-dev"
+                    "dev-master": "3.0-dev"
                 }
             },
             "autoload": {
                 "psr-4": {
                     "Symfony\\Component\\Console\\": ""
-                }
+                },
+                "exclude-from-classmap": [
+                    "/Tests/"
+                ]
             },
             "notification-url": "https://packagist.org/downloads/",
             "license": [
             ],
             "description": "Symfony Console Component",
             "homepage": "https://symfony.com",
-            "time": "2015-09-03 11:40:38"
+            "time": "2016-02-02 13:44:19"
         },
         {
             "name": "symfony/finder",
             "time": "2016-01-27 05:14:46"
         },
         {
+            "name": "symfony/polyfill-mbstring",
+            "version": "v1.1.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/symfony/polyfill-mbstring.git",
+                "reference": "1289d16209491b584839022f29257ad859b8532d"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/1289d16209491b584839022f29257ad859b8532d",
+                "reference": "1289d16209491b584839022f29257ad859b8532d",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=5.3.3"
+            },
+            "suggest": {
+                "ext-mbstring": "For best performance"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "1.1-dev"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Symfony\\Polyfill\\Mbstring\\": ""
+                },
+                "files": [
+                    "bootstrap.php"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Nicolas Grekas",
+                    "email": "p@tchwork.com"
+                },
+                {
+                    "name": "Symfony Community",
+                    "homepage": "https://symfony.com/contributors"
+                }
+            ],
+            "description": "Symfony polyfill for the Mbstring extension",
+            "homepage": "https://symfony.com",
+            "keywords": [
+                "compatibility",
+                "mbstring",
+                "polyfill",
+                "portable",
+                "shim"
+            ],
+            "time": "2016-01-20 09:13:37"
+        },
+        {
             "name": "typo3/class-alias-loader",
             "version": "1.0.0",
             "source": {
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Breaking-73152-SymfonyConsoleHelpersReplaced.rst b/typo3/sysext/core/Documentation/Changelog/master/Breaking-73152-SymfonyConsoleHelpersReplaced.rst
new file mode 100644 (file)
index 0000000..33612e3
--- /dev/null
@@ -0,0 +1,47 @@
+===================================================
+Breaking: #73152 - Symfony console helpers replaced
+===================================================
+
+Description
+===========
+
+By upgrading to Symfony Console 3.x the ``DialogHelper``, ``ProgressHelper`` and
+``TableHelper`` have been replaced. The internal getter methods for these classes
+have been replaced in Extbase ``ConsoleOutput``.
+
+
+Impact
+======
+
+Calling the following methods with result in a fatal error:
+
+- ``ConsoleOutput::getDialogHelper()``
+- ``ConsoleOutput::getProgressHelper()``
+- ``ConsoleOutput::getTableHelper()``
+
+The 2nd argument of the following methods is ignored now:
+
+- ``ConsoleOutput::progressAdvance()``
+- ``ConsoleOutput::progressSet()``
+
+
+Affected Installations
+======================
+
+Extensions which have directly called these methods in favor of the Extbase
+``ConsoleOutput`` helper methods.
+
+
+Migration
+=========
+
+Use the following methods instead:
+
+- ``ConsoleOutput::getQuestionHelper()``
+- ``ConsoleOutput::getProgressBar()``
+- ``ConsoleOutput::getTable()``
+
+Remove the 2nd argument when calling these methods:
+
+- ``ConsoleOutput::progressAdvance()``
+- ``ConsoleOutput::progressSet()``
index 4cff5a9..37b8522 100644 (file)
@@ -15,12 +15,16 @@ namespace TYPO3\CMS\Extbase\Mvc\Cli;
  */
 
 use Symfony\Component\Console\Formatter\OutputFormatterStyle;
-use Symfony\Component\Console\Helper\DialogHelper;
 use Symfony\Component\Console\Helper\FormatterHelper;
 use Symfony\Component\Console\Helper\HelperSet;
-use Symfony\Component\Console\Helper\ProgressHelper;
-use Symfony\Component\Console\Helper\TableHelper;
+use Symfony\Component\Console\Helper\ProgressBar;
+use Symfony\Component\Console\Helper\QuestionHelper;
+use Symfony\Component\Console\Helper\Table;
+use Symfony\Component\Console\Input\ArgvInput;
 use Symfony\Component\Console\Output\ConsoleOutput as SymfonyConsoleOutput;
+use Symfony\Component\Console\Question\ChoiceQuestion;
+use Symfony\Component\Console\Question\ConfirmationQuestion;
+use Symfony\Component\Console\Question\Question;
 
 /**
  * A wrapper for Symfony ConsoleOutput and related helpers
@@ -28,32 +32,39 @@ use Symfony\Component\Console\Output\ConsoleOutput as SymfonyConsoleOutput;
 class ConsoleOutput
 {
     /**
+     * @var ArgvInput
+     */
+    protected $input;
+
+    /**
      * @var SymfonyConsoleOutput
      */
     protected $output;
 
     /**
-     * @var DialogHelper
+     * @var QuestionHelper
      */
-    protected $dialogHelper;
+    protected $questionHelper;
 
     /**
-     * @var ProgressHelper
+     * @var ProgressBar
      */
-    protected $progressHelper;
+    protected $progressBar;
 
     /**
-     * @var TableHelper
+     * @var Table
      */
-    protected $tableHelper;
+    protected $table;
 
     /**
-     * Creates and initializes the SymfonyConsoleOutput instance
+     * Creates and initializes the Symfony I/O instances
      *
      * @return void
      */
     public function __construct()
     {
+        $this->input = new ArgvInput();
+
         $this->output = new SymfonyConsoleOutput();
         $this->output->getFormatter()->setStyle('b', new OutputFormatterStyle(null, null, array('bold')));
         $this->output->getFormatter()->setStyle('i', new OutputFormatterStyle('black', 'white'));
@@ -130,12 +141,12 @@ class ConsoleOutput
      */
     public function outputTable($rows, $headers = null)
     {
-        $tableHelper = $this->getTableHelper();
+        $table = $this->getTable();
         if ($headers !== null) {
-            $tableHelper->setHeaders($headers);
+            $table->setHeaders($headers);
         }
-        $tableHelper->setRows($rows);
-        $tableHelper->render($this->output);
+        $table->setRows($rows);
+        $table->render();
     }
 
     /**
@@ -151,7 +162,12 @@ class ConsoleOutput
      */
     public function select($question, $choices, $default = null, $multiSelect = false, $attempts = false)
     {
-        return $this->getDialogHelper()->select($this->output, $question, $choices, $default, $attempts, 'Value "%s" is invalid', $multiSelect);
+        $question = (new ChoiceQuestion($question, $choices, $default))
+            ->setMultiselect($multiSelect)
+            ->setMaxAttempts($attempts)
+            ->setErrorMessage('Value "%s" is invalid');
+
+        return $this->getQuestionHelper()->ask($this->input, $this->output, $question);
     }
 
     /**
@@ -165,7 +181,10 @@ class ConsoleOutput
      */
     public function ask($question, $default = null, array $autocomplete = null)
     {
-        return $this->getDialogHelper()->ask($this->output, $question, $default, $autocomplete);
+        $question = (new Question($question, $default))
+            ->setAutocompleterValues($autocomplete);
+
+        return $this->getQuestionHelper()->ask($this->input, $this->output, $question);
     }
 
     /**
@@ -179,7 +198,9 @@ class ConsoleOutput
      */
     public function askConfirmation($question, $default = true)
     {
-        return $this->getDialogHelper()->askConfirmation($this->output, $question, $default);
+        $question = new ConfirmationQuestion($question, $default);
+
+        return $this->getQuestionHelper()->ask($this->input, $this->output, $question);
     }
 
     /**
@@ -192,7 +213,11 @@ class ConsoleOutput
      */
     public function askHiddenResponse($question, $fallback = true)
     {
-        return $this->getDialogHelper()->askHiddenResponse($this->output, $question, $fallback);
+        $question = (new Question($question))
+            ->setHidden(true)
+            ->setHiddenFallback($fallback);
+
+        return $this->getQuestionHelper()->ask($this->input, $this->output, $question);
     }
 
     /**
@@ -212,7 +237,12 @@ class ConsoleOutput
      */
     public function askAndValidate($question, $validator, $attempts = false, $default = null, array $autocomplete = null)
     {
-        return $this->getDialogHelper()->askAndValidate($this->output, $question, $validator, $attempts, $default, $autocomplete);
+        $question = (new Question($question, $default))
+            ->setValidator($validator)
+            ->setMaxAttempts($attempts)
+            ->setAutocompleterValues($autocomplete);
+
+        return $this->getQuestionHelper()->ask($this->input, $this->output, $question);
     }
 
     /**
@@ -232,7 +262,13 @@ class ConsoleOutput
      */
     public function askHiddenResponseAndValidate($question, $validator, $attempts = false, $fallback = true)
     {
-        return $this->getDialogHelper()->askHiddenResponseAndValidate($this->output, $question, $validator, $attempts, $fallback);
+        $question = (new Question($question))
+            ->setValidator($validator)
+            ->setMaxAttempts($attempts)
+            ->setHidden(true)
+            ->setHiddenFallback($fallback);
+
+        return $this->getQuestionHelper()->ask($this->input, $this->output, $question);
     }
 
     /**
@@ -243,33 +279,31 @@ class ConsoleOutput
      */
     public function progressStart($max = null)
     {
-        $this->getProgressHelper()->start($this->output, $max);
+        $this->getProgressBar()->start($max);
     }
 
     /**
      * Advances the progress output X steps
      *
      * @param int $step Number of steps to advance
-     * @param bool $redraw Whether to redraw or not
      * @return void
      * @throws \LogicException
      */
-    public function progressAdvance($step = 1, $redraw = false)
+    public function progressAdvance($step = 1)
     {
-        $this->getProgressHelper()->advance($step, $redraw);
+        $this->getProgressBar()->advance($step);
     }
 
     /**
      * Sets the current progress
      *
      * @param int $current The current progress
-     * @param bool $redraw Whether to redraw or not
      * @return void
      * @throws \LogicException
      */
-    public function progressSet($current, $redraw = false)
+    public function progressSet($current)
     {
-        $this->getProgressHelper()->setCurrent($current, $redraw);
+        $this->getProgressBar()->setProgress($current);
     }
 
     /**
@@ -279,47 +313,47 @@ class ConsoleOutput
      */
     public function progressFinish()
     {
-        $this->getProgressHelper()->finish();
+        $this->getProgressBar()->finish();
     }
 
     /**
-     * Returns or initializes the symfony/console DialogHelper
+     * Returns or initializes the symfony/console QuestionHelper
      *
-     * @return DialogHelper
+     * @return QuestionHelper
      */
-    protected function getDialogHelper()
+    protected function getQuestionHelper()
     {
-        if ($this->dialogHelper === null) {
-            $this->dialogHelper = new DialogHelper(false);
+        if ($this->questionHelper === null) {
+            $this->questionHelper = new QuestionHelper();
             $helperSet = new HelperSet(array(new FormatterHelper()));
-            $this->dialogHelper->setHelperSet($helperSet);
+            $this->questionHelper->setHelperSet($helperSet);
         }
-        return $this->dialogHelper;
+        return $this->questionHelper;
     }
 
     /**
-     * Returns or initializes the symfony/console ProgressHelper
+     * Returns or initializes the symfony/console ProgressBar
      *
-     * @return ProgressHelper
+     * @return ProgressBar
      */
-    protected function getProgressHelper()
+    protected function getProgressBar()
     {
-        if ($this->progressHelper === null) {
-            $this->progressHelper = new ProgressHelper(false);
+        if ($this->progressBar === null) {
+            $this->progressBar = new ProgressBar($this->output);
         }
-        return $this->progressHelper;
+        return $this->progressBar;
     }
 
     /**
-     * Returns or initializes the symfony/console TableHelper
+     * Returns or initializes the symfony/console Table
      *
-     * @return TableHelper
+     * @return Table
      */
-    protected function getTableHelper()
+    protected function getTable()
     {
-        if ($this->tableHelper === null) {
-            $this->tableHelper = new TableHelper(false);
+        if ($this->table === null) {
+            $this->table = new Table($this->output);
         }
-        return $this->tableHelper;
+        return $this->table;
     }
 }