[FEATURE] CLI command to install and uninstall extensions by key 35/23535/4
authorClaus Due <claus@namelesscoder.net>
Sun, 1 Sep 2013 21:26:28 +0000 (23:26 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Mon, 2 Sep 2013 20:20:56 +0000 (22:20 +0200)
This change adds a CommandContoller for EXT:extensionmanager;
this new ComandController contains two actions (install, uninstall)
which is then handled by the Utility which contains the actual logic.

Usage example: ./typo3/cli_dispatch.phpsh extbase extension:install [key]

Resolves: #51629
Releases: 6.2
Change-Id: I3561a427f4eff4c5041326f706ed8c77bbbbe9be
Reviewed-on: https://review.typo3.org/23535
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
typo3/sysext/extensionmanager/Classes/Command/ExtensionCommandController.php [new file with mode: 0644]
typo3/sysext/extensionmanager/ext_localconf.php

diff --git a/typo3/sysext/extensionmanager/Classes/Command/ExtensionCommandController.php b/typo3/sysext/extensionmanager/Classes/Command/ExtensionCommandController.php
new file mode 100644 (file)
index 0000000..1c57798
--- /dev/null
@@ -0,0 +1,70 @@
+<?php
+namespace TYPO3\CMS\Extensionmanager\Command;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2013 Claus Due <claus@namelesscoder.net>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *  A copy is found in the textfile GPL.txt and important notices to the license
+ *  from the author is found in LICENSE.txt distributed with these scripts.
+ *
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+use TYPO3\CMS\Extbase\Mvc\Controller\CommandController;
+
+/**
+ * CommandController for working with extension management through CLI/scheduler
+ *
+ * @author Claus Due <claus@namelesscoder.net>
+ */
+class ExtensionCommandController extends CommandController {
+
+       /**
+        * Installs an extension by key
+        *
+        * The extension files must be present in one of the
+        * recognised extension folder paths in TYPO3.
+        *
+        * @param string $extensionKey
+        * @return void
+        */
+       public function installCommand($extensionKey) {
+               /** @var $service \TYPO3\CMS\Extensionmanager\Utility\InstallUtility */
+               $service = $this->objectManager->get('TYPO3\\CMS\\Extensionmanager\\Utility\\InstallUtility');
+               $service->install($extensionKey);
+       }
+
+       /**
+        * Uninstalls an extension by key
+        *
+        * The extension files must be present in one of the
+        * recognised extension folder paths in TYPO3.
+        *
+        * @param string $extensionKey
+        * @return void
+        */
+       public function uninstallCommand($extensionKey) {
+               /** @var $service \TYPO3\CMS\Extensionmanager\Utility\InstallUtility */
+               $service = $this->objectManager->get('TYPO3\\CMS\\Extensionmanager\\Utility\\InstallUtility');
+               $service->uninstall($extensionKey);
+       }
+
+}
+?>
\ No newline at end of file
index f2dc782..24eb3a5 100644 (file)
@@ -10,4 +10,9 @@ $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks']['TYPO3\\CMS\\Ext
        'description' => 'LLL:EXT:' . $_EXTKEY . '/Resources/Private/Language/locallang.xlf:task.updateExtensionListTask.description',
        'additionalFields' => '',
 );
+
+if (TYPO3_MODE === 'BE') {
+       $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['extbase']['commandControllers'][] = 'TYPO3\\CMS\\Extensionmanager\\Command\\ExtensionCommandController';
+}
+
 ?>
\ No newline at end of file