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

Commit c65a2c0

Browse files
author
Georg Ringer
committed
[FEATURE] EM info task
1 parent db03364 commit c65a2c0

File tree

2 files changed

+86
-5
lines changed

2 files changed

+86
-5
lines changed

Classes/Command/ExtensionApiCommandController.php

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
2-
/***************************************************************
2+
3+
/* * *************************************************************
34
* Copyright notice
45
*
56
* (c) 2012 Georg Ringer <[email protected]>
@@ -20,7 +21,7 @@
2021
* GNU General Public License for more details.
2122
*
2223
* This copyright notice MUST APPEAR in all copies of the script!
23-
***************************************************************/
24+
* ************************************************************* */
2425

2526
/**
2627
* Extension API Command Controller
@@ -30,14 +31,74 @@
3031
*/
3132
class Tx_Coreapi_Command_ExtensionApiCommandController extends Tx_Extbase_MVC_Controller_CommandController {
3233

34+
/**
35+
* Information about an extension
36+
*
37+
* @param string $key extension key
38+
* @return void
39+
*/
40+
public function infoCommand($key) {
41+
$data = array();
42+
try {
43+
/** @var $service Tx_Coreapi_Service_ExtensionApiService */
44+
$service = $this->objectManager->get('Tx_Coreapi_Service_ExtensionApiService');
45+
$data = $service->getExtensionInformation($key);
46+
} catch (Exception $e) {
47+
$this->outputLine($e->getMessage());
48+
$this->quit();
49+
}
50+
51+
$this->outputLine('');
52+
$this->outputLine('EXTENSION "%s": %s %s', array(strtoupper($key), $data['em_conf']['version'], $data['em_conf']['state']));
53+
$this->outputLine(str_repeat('-', self::MAXIMUM_LINE_LENGTH));
54+
55+
$outputInformation = array();
56+
$outputInformation['is installed'] = ($data['is_installed'] ? 'yes' : 'no');
57+
foreach($data['em_conf'] as $emConfKey => $emConfValue) {
58+
// Skip empty properties
59+
if (empty($emConfValue)) {
60+
continue;
61+
}
62+
// Skip properties which are already handled
63+
if ($emConfKey === 'title' || $emConfKey === 'version' || $emConfKey === 'state') {
64+
continue;
65+
}
66+
$outputInformation[$emConfKey] = $emConfValue;
67+
}
68+
69+
foreach ($outputInformation as $outputKey => $outputValue) {
70+
$description = '';
71+
if (is_array($outputValue)) {
72+
foreach ($outputValue as $additionalKey => $additionalValue) {
73+
if (is_array($additionalValue)) {
74+
75+
if (empty($additionalValue)) {
76+
continue;
77+
}
78+
$description .= LF . str_repeat(' ', 28) . $additionalKey;
79+
$description .= LF;
80+
foreach ($additionalValue as $ak => $av) {
81+
$description .= str_repeat(' ', 30) . $ak . ': ' . $av . LF;
82+
}
83+
} else {
84+
$description .= LF . str_repeat(' ', 28) . $additionalKey . ': '. $additionalValue;
85+
}
86+
}
87+
} else {
88+
$description = wordwrap($outputValue, self::MAXIMUM_LINE_LENGTH - 28, PHP_EOL . str_repeat(' ', 28), TRUE);
89+
}
90+
$this->outputLine('%-2s%-25s %s', array(' ', $outputKey, $description));
91+
}
92+
}
93+
3394
/**
3495
* List all installed extensions
3596
*
3697
* @param string $type Extension type, can either be L for local, S for system or G for global. Leave it empty for all
3798
* @return void
3899
*/
39100
public function listInstalledCommand($type = '') {
40-
$type = strtoupper($type);
101+
$type = strtoupper($type);
41102
if (!empty($type) && $type !== 'L' && $type !== 'G' && $type !== 'S') {
42103
$this->outputLine('Only "L", "S" and "G" are supported as type (or nothing)');
43104
$this->quit();

Classes/Service/ExtensionApiService.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,35 @@
3131
class Tx_Coreapi_Service_ExtensionApiService {
3232
/*
3333
extension Provides some basic information on the site's extension status
34-
extension:info Fetches the latest (or provided) version of an extension from TER
35-
extension:list Lists all available extensions of a site
34+
[x] extension:info Fetches the latest (or provided) version of an extension from TER
35+
[x] extension:list Lists all available extensions of a site
3636
extension:search Searches for an extension in the TER
3737
extension:fetch Fetches the latest (or provided) version of an extension from TER
3838
extension:install Installs the latest (or provided) version of an extension
3939
extension:uninstall Uninstalls an extension
4040
extension:refresh Refreshes the local cache of all extensions available in TER
4141
*/
4242

43+
/**
44+
* Get information about an extension
45+
*
46+
* @param string $key extension key
47+
* @return array
48+
*/
49+
public function getExtensionInformation($key) {
50+
if (!$GLOBALS['TYPO3_LOADED_EXT'][$key]) {
51+
throw new Exception(sprintf('Extension "%s" not found.', $key));
52+
}
53+
54+
include_once(t3lib_extMgm::extPath($key) . 'ext_emconf.php');
55+
$information = array(
56+
'em_conf' => $EM_CONF[''],
57+
'isLoaded' => t3lib_extMgm::isLoaded($key)
58+
);
59+
60+
return $information;
61+
}
62+
4363
public function getInstalledExtensions($type = '') {
4464
$extensions = $GLOBALS['TYPO3_LOADED_EXT'];
4565

0 commit comments

Comments
 (0)