|
1 | 1 | <?php |
2 | | -/*************************************************************** |
| 2 | + |
| 3 | +/* * ************************************************************* |
3 | 4 | * Copyright notice |
4 | 5 | * |
5 | 6 | * (c) 2012 Georg Ringer <[email protected]> |
|
20 | 21 | * GNU General Public License for more details. |
21 | 22 | * |
22 | 23 | * This copyright notice MUST APPEAR in all copies of the script! |
23 | | - ***************************************************************/ |
| 24 | + * ************************************************************* */ |
24 | 25 |
|
25 | 26 | /** |
26 | 27 | * Extension API Command Controller |
|
30 | 31 | */ |
31 | 32 | class Tx_Coreapi_Command_ExtensionApiCommandController extends Tx_Extbase_MVC_Controller_CommandController { |
32 | 33 |
|
| 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 | + |
33 | 94 | /** |
34 | 95 | * List all installed extensions |
35 | 96 | * |
36 | 97 | * @param string $type Extension type, can either be L for local, S for system or G for global. Leave it empty for all |
37 | 98 | * @return void |
38 | 99 | */ |
39 | 100 | public function listInstalledCommand($type = '') { |
40 | | - $type = strtoupper($type); |
| 101 | + $type = strtoupper($type); |
41 | 102 | if (!empty($type) && $type !== 'L' && $type !== 'G' && $type !== 'S') { |
42 | 103 | $this->outputLine('Only "L", "S" and "G" are supported as type (or nothing)'); |
43 | 104 | $this->quit(); |
|
0 commit comments