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

Commit aadd3f4

Browse files
author
xwm
committed
[TASK] added install, uninstall, configure, fetch and import commands to Cli/Dispatcher.php for compatibility with TYPO3 version 4.5 and 4.6
1 parent 2de18ed commit aadd3f4

File tree

1 file changed

+142
-0
lines changed

1 file changed

+142
-0
lines changed

Classes/Cli/Dispatcher.php

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,148 @@ public function extensionListinstalledCommand($type=''){
334334

335335
}
336336

337+
338+
339+
/**
340+
* Install(activate) an extension
341+
*
342+
* @param string $key extension key
343+
* @return void
344+
*/
345+
public function extensionInstallCommand($key) {
346+
347+
$service = t3lib_div::makeInstance('Tx_Coreapi_Service_ExtensionApiService');
348+
$data = $service->installExtension($key);
349+
$this->outputLine(sprintf('Extension "%s" is now installed!', $key));
350+
351+
}
352+
353+
354+
/**
355+
* UnInstall(deactivate) an extension
356+
*
357+
* @param string $key extension key
358+
* @return void
359+
*/
360+
public function extensionUninstallCommand($key) {
361+
362+
$service = t3lib_div::makeInstance('Tx_Coreapi_Service_ExtensionApiService');
363+
$data = $service->unInstallExtension($key);
364+
$this->outputLine(sprintf('Extension "%s" is now uninstalled!', $key));
365+
366+
}
367+
368+
369+
370+
/**
371+
* Configure an extension
372+
*
373+
* This command enables you to configure an extension.
374+
*
375+
* examples:
376+
*
377+
* [1] Using a standard formatted ini-file
378+
* ./cli_dispatch.phpsh coreapi extension:configure rtehtmlarea --configfile=C:\rteconf.txt
379+
*
380+
* [2] Adding configuration settings directly on the command line
381+
* ./cli_dispatch.phpsh coreapi extension:configure rtehtmlarea --settings="enableImages=1;allowStyleAttribute=0"
382+
*
383+
* [3] A combination of [1] and [2]
384+
* ./cli_dispatch.phpsh extbase extension:configure rtehtmlarea --configfile=C:\rteconf.txt --settings="enableImages=1;allowStyleAttribute=0"
385+
*
386+
*
387+
*
388+
* @param string $key extension key
389+
* @param string $configfile path to file containing configuration settings. Must be formatted as a standard ini-file
390+
* @param string $settings string containing configuration settings separated on the form "k1=v1;k2=v2;"
391+
* @return void
392+
*/
393+
public function extensionConfigureCommand($key, $configfile='',$settings='') {
394+
395+
global $TYPO3_CONF_VARS;
396+
397+
398+
$service = t3lib_div::makeInstance('Tx_Coreapi_Service_ExtensionApiService');
399+
400+
$conf = array();
401+
402+
if(is_file($configfile)){
403+
404+
$conf = parse_ini_file($configfile);
405+
406+
}
407+
408+
if(strlen($settings)){
409+
$arr = explode(';',$settings);
410+
foreach($arr as $v){
411+
if(strpos($v,'=') === FALSE){
412+
413+
throw new InvalidArgumentException(sprintf('Ill-formed setting "%s"!', $v));
414+
415+
}
416+
$parts = t3lib_div::trimExplode('=', $v,FALSE,2);
417+
418+
if(!empty($parts[0])){
419+
$conf[$parts[0]] = $parts[1];
420+
}
421+
}
422+
}
423+
424+
if(empty($conf)){
425+
426+
throw new InvalidArgumentException(sprintf('No configuration settings!', $key));
427+
428+
}
429+
430+
$data = $service->configureExtension($key,$conf);
431+
432+
433+
$this->outputLine(sprintf('Extension "%s" has been configured!', $key));
434+
435+
}
436+
437+
438+
439+
/**
440+
* Fetch an extension from TER
441+
*
442+
* @param string $key extension key
443+
* @param string $version the exact version of the extension, otherwise the latest will be picked
444+
* @param string $location where to put the extension. S = typo3/sysext, G = typo3/ext, L = typo3conf/ext
445+
* @param string $overwrite overwrite the extension if it already exists
446+
* @param string $mirror mirror to fetch the extension from, otherwise a random mirror will be selected
447+
* @return void
448+
*/
449+
450+
public function extensionFetchCommand($key, $version='', $location='L', $overwrite = FALSE, $mirror = ''){
451+
452+
$service = t3lib_div::makeInstance('Tx_Coreapi_Service_ExtensionApiService');
453+
$data = $service->fetchExtension($key, $version, $location, $overwrite,$mirror);
454+
$this->outputLine(sprintf('Extension "%s" version %s has been fetched from repository!', $data['extKey'],$data['version']));
455+
456+
}
457+
458+
459+
460+
/**
461+
* Import extension from file
462+
*
463+
* @param string $file path to t3x file
464+
* @param string $location where to import the extension. S = typo3/sysext, G = typo3/ext, L = typo3conf/ext
465+
* @param boolean $overwrite overwrite the extension if it already exists
466+
* @return void
467+
*/
468+
469+
public function extensionImportCommand($file, $location='L', $overwrite = FALSE){
470+
471+
$service = t3lib_div::makeInstance('Tx_Coreapi_Service_ExtensionApiService');
472+
$data = $service->importExtension($file,$location,$overwrite);
473+
$this->outputLine(sprintf('Extension "%s" has been imported!', $data['extKey']));
474+
475+
}
476+
477+
478+
337479
/**
338480
* Site info
339481
*

0 commit comments

Comments
 (0)