Skip to content
This repository was archived by the owner on Aug 15, 2023. It is now read-only.

Commit 90bc75e

Browse files
committed
Merge branch 'madsbrunn/master' (closes #13)
2 parents 5d53d78 + f70654c commit 90bc75e

File tree

8 files changed

+1138
-201
lines changed

8 files changed

+1138
-201
lines changed

Classes/Cli/Dispatcher.php

Lines changed: 517 additions & 159 deletions
Large diffs are not rendered by default.

Classes/Command/CacheApiCommandController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ public function clearPageCacheCommand() {
6868

6969
$this->outputLine('Page cache has been cleared.');
7070
}
71-
7271
}
7372

7473
?>

Classes/Command/DatabaseApiCommandController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ public function databaseCompareCommand($actions = '') {
5757
$this->quit();
5858
}
5959
}
60-
6160
}
6261

6362
?>

Classes/Command/ExtensionApiCommandController.php

Lines changed: 142 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
/* * *************************************************************
3+
/***************************************************************
44
* Copyright notice
55
*
66
* (c) 2012 Georg Ringer <[email protected]>
@@ -21,7 +21,7 @@
2121
* GNU General Public License for more details.
2222
*
2323
* This copyright notice MUST APPEAR in all copies of the script!
24-
* ************************************************************* */
24+
***************************************************************/
2525

2626
/**
2727
* Extension API Command Controller
@@ -54,12 +54,12 @@ public function infoCommand($key) {
5454

5555
$outputInformation = array();
5656
$outputInformation['is installed'] = ($data['is_installed'] ? 'yes' : 'no');
57-
foreach($data['em_conf'] as $emConfKey => $emConfValue) {
58-
// Skip empty properties
57+
foreach ($data['em_conf'] as $emConfKey => $emConfValue) {
58+
// Skip empty properties
5959
if (empty($emConfValue)) {
6060
continue;
6161
}
62-
// Skip properties which are already handled
62+
// Skip properties which are already handled
6363
if ($emConfKey === 'title' || $emConfKey === 'version' || $emConfKey === 'state') {
6464
continue;
6565
}
@@ -72,7 +72,7 @@ public function infoCommand($key) {
7272
foreach ($outputValue as $additionalKey => $additionalValue) {
7373
if (is_array($additionalValue)) {
7474

75-
if (empty($additionalValue)) {
75+
if (empty($additionalValue)) {
7676
continue;
7777
}
7878
$description .= LF . str_repeat(' ', 28) . $additionalKey;
@@ -81,7 +81,7 @@ public function infoCommand($key) {
8181
$description .= str_repeat(' ', 30) . $ak . ': ' . $av . LF;
8282
}
8383
} else {
84-
$description .= LF . str_repeat(' ', 28) . $additionalKey . ': '. $additionalValue;
84+
$description .= LF . str_repeat(' ', 28) . $additionalKey . ': ' . $additionalValue;
8585
}
8686
}
8787
} else {
@@ -131,6 +131,141 @@ public function updateListCommand() {
131131
$this->outputLine('Extension list has been updated.');
132132
}
133133

134+
/**
135+
* Install(activate) an extension
136+
*
137+
* @param string $key extension key
138+
* @return void
139+
*/
140+
public function installCommand($key) {
141+
try {
142+
/** @var $service Tx_Coreapi_Service_ExtensionApiService */
143+
$service = $this->objectManager->get('Tx_Coreapi_Service_ExtensionApiService');
144+
$data = $service->installExtension($key);
145+
} catch (Exception $e) {
146+
$this->outputLine($e->getMessage());
147+
$this->quit();
148+
}
149+
$this->outputLine(sprintf('Extension "%s" is now installed!', $key));
150+
}
151+
152+
/**
153+
* UnInstall(deactivate) an extension
154+
*
155+
* @param string $key extension key
156+
* @return void
157+
*/
158+
public function uninstallCommand($key) {
159+
try {
160+
/** @var $service Tx_Coreapi_Service_ExtensionApiService */
161+
$service = $this->objectManager->get('Tx_Coreapi_Service_ExtensionApiService');
162+
$data = $service->uninstallExtension($key);
163+
} catch (Exception $e) {
164+
$this->outputLine($e->getMessage());
165+
$this->quit();
166+
}
167+
$this->outputLine(sprintf('Extension "%s" is now uninstalled!', $key));
168+
}
169+
170+
/**
171+
* Configure an extension
172+
*
173+
* This command enables you to configure an extension.
174+
*
175+
* examples:
176+
*
177+
* [1] Using a standard formatted ini-file
178+
* ./cli_dispatch.phpsh extbase extensionapi:configure rtehtmlarea --configfile=C:\rteconf.txt
179+
*
180+
* [2] Adding configuration settings directly on the command line
181+
* ./cli_dispatch.phpsh extbase extensionapi:configure rtehtmlarea --settings="enableImages=1;allowStyleAttribute=0"
182+
*
183+
* [3] A combination of [1] and [2]
184+
* ./cli_dispatch.phpsh extbase extensionapi:configure rtehtmlarea --configfile=C:\rteconf.txt --settings="enableImages=1;allowStyleAttribute=0"
185+
*
186+
* @param string $key extension key
187+
* @param string $configfile path to file containing configuration settings. Must be formatted as a standard ini-file
188+
* @param string $settings string containing configuration settings separated on the form "k1=v1;k2=v2;"
189+
* @return void
190+
*/
191+
public function configureCommand($key, $configfile = '', $settings = '') {
192+
global $TYPO3_CONF_VARS;
193+
try {
194+
/** @var $service Tx_Coreapi_Service_ExtensionApiService */
195+
$service = $this->objectManager->get('Tx_Coreapi_Service_ExtensionApiService');
196+
$conf = array();
197+
if (is_file($configfile)) {
198+
$conf = parse_ini_file($configfile);
199+
}
200+
201+
if (strlen($settings)) {
202+
$arr = explode(';', $settings);
203+
foreach ($arr as $v) {
204+
if (strpos($v, '=') === FALSE) {
205+
throw new InvalidArgumentException(sprintf('Ill-formed setting "%s"!', $v));
206+
}
207+
$parts = t3lib_div::trimExplode('=', $v, FALSE, 2);
208+
if (!empty($parts[0])) {
209+
$conf[$parts[0]] = $parts[1];
210+
}
211+
}
212+
}
213+
214+
if (empty($conf)) {
215+
throw new InvalidArgumentException(sprintf('No configuration settings!', $key));
216+
}
217+
$data = $service->configureExtension($key, $conf);
218+
219+
} catch (Exception $e) {
220+
$this->outputLine($e->getMessage());
221+
$this->quit();
222+
}
223+
$this->outputLine(sprintf('Extension "%s" has been configured!', $key));
224+
}
225+
226+
/**
227+
* Fetch an extension from TER
228+
*
229+
* @param string $key extension key
230+
* @param string $version the exact version of the extension, otherwise the latest will be picked
231+
* @param string $location where to put the extension. S = typo3/sysext, G = typo3/ext, L = typo3conf/ext
232+
* @param bool $overwrite overwrite the extension if it already exists
233+
* @param string $mirror mirror to fetch the extension from, otherwise a random mirror will be selected
234+
* @return void
235+
*/
236+
public function fetchCommand($key, $version = '', $location = 'L', $overwrite = FALSE, $mirror = '') {
237+
try {
238+
/** @var $service Tx_Coreapi_Service_ExtensionApiService */
239+
$service = $this->objectManager->get('Tx_Coreapi_Service_ExtensionApiService');
240+
$data = $service->fetchExtension($key, $version, $location, $overwrite, $mirror);
241+
$this->outputLine(sprintf('Extension "%s" version %s has been fetched from repository!', $data['extKey'], $data['version']));
242+
} catch (Exception $e) {
243+
$this->outputLine($e->getMessage());
244+
$this->quit();
245+
}
246+
}
247+
248+
/**
249+
* Import extension from file
250+
*
251+
* @param string $file path to t3x file
252+
* @param string $location where to import the extension. S = typo3/sysext, G = typo3/ext, L = typo3conf/ext
253+
* @param boolean $overwrite overwrite the extension if it already exists
254+
* @return void
255+
*/
256+
public function importCommand($file, $location = 'L', $overwrite = FALSE) {
257+
try {
258+
/** @var $service Tx_Coreapi_Service_ExtensionApiService */
259+
$service = $this->objectManager->get('Tx_Coreapi_Service_ExtensionApiService');
260+
$data = $service->importExtension($file, $location, $overwrite);
261+
$this->outputLine(sprintf('Extension "%s" has been imported!', $data['extKey']));
262+
263+
} catch (Exception $e) {
264+
$this->outputLine($e->getMessage());
265+
$this->quit();
266+
}
267+
}
268+
134269
/**
135270
* createUploadFoldersCommand
136271
*
@@ -149,7 +284,6 @@ public function createUploadFoldersCommand() {
149284
$this->outputLine('no uploadFolder created');
150285
}
151286
}
152-
153287
}
154288

155289
?>

Classes/Command/SiteApiCommandController.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function infoCommand() {
4242
$service = $this->objectManager->get('Tx_Coreapi_Service_SiteApiService');
4343
$data = $service->getSiteInfo();
4444

45-
foreach($data as $key => $value) {
45+
foreach ($data as $key => $value) {
4646
$line = wordwrap($value, self::MAXIMUM_LINE_LENGTH - 43, PHP_EOL . str_repeat(' ', 43), TRUE);
4747
$this->outputLine('%-2s%-40s %s', array(' ', $key, $line));
4848
}
@@ -62,7 +62,6 @@ public function createSysNewsCommand($header, $text = '') {
6262
$service = $this->objectManager->get('Tx_Coreapi_Service_SiteApiService');
6363
$service->createSysNews($header, $text);
6464
}
65-
6665
}
6766

6867
?>

Classes/Service/CacheApiService.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ public function clearConfigurationCache() {
7777
}
7878
$this->tce->clear_cacheCmd('temp_cached');
7979
}
80-
8180
}
8281

8382
?>

Classes/Service/DatabaseApiService.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
/* * *************************************************************
3+
/***************************************************************
44
* Copyright notice
55
*
66
* (c) 2012 Georg Ringer <[email protected]>
@@ -21,7 +21,7 @@
2121
* GNU General Public License for more details.
2222
*
2323
* This copyright notice MUST APPEAR in all copies of the script!
24-
* ************************************************************* */
24+
***************************************************************/
2525

2626
/**
2727
* DB API service
@@ -48,7 +48,13 @@ class Tx_Coreapi_Service_DatabaseApiService {
4848
* Constructor function
4949
*/
5050
public function __construct() {
51-
$this->sqlHandler = t3lib_div::makeInstance('t3lib_install_Sql');
51+
if (class_exists('TYPO3\\CMS\\Install\\Sql\\SchemaMigrator')) {
52+
$this->sqlHandler = t3lib_div::makeInstance('TYPO3\\CMS\\Install\\Sql\\SchemaMigrator');
53+
} elseif (class_exists('t3lib_install_Sql')) {
54+
$this->sqlHandler = t3lib_div::makeInstance('t3lib_install_Sql');
55+
} elseif (class_exists('t3lib_install')) {
56+
$this->sqlHandler = t3lib_div::makeInstance('t3lib_install');
57+
}
5258
}
5359

5460
/**

0 commit comments

Comments
 (0)