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

Commit e2cebe5

Browse files
author
Georg Ringer
committed
CGL + docs
1 parent bcc9f89 commit e2cebe5

File tree

5 files changed

+31
-18
lines changed

5 files changed

+31
-18
lines changed

Classes/Cli/Dispatcher.php

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
* This script must be included by the "CLI module dispatcher"
2828
*
2929
* @author Georg Ringer <[email protected]>
30-
* @package TYPO3
30+
* @package TYPO3
3131
* @subpackage tx_coreapi
3232
*/
3333
class Tx_Coreapi_Cli_Dispatcher {
@@ -51,12 +51,14 @@ class Tx_Coreapi_Cli_Dispatcher {
5151
*/
5252
public function __construct() {
5353
if (!isset($_SERVER['argv'][1])) {
54-
die('ERROR: No service defined');
54+
$this->error('No service defined');
5555
}
5656

5757
$split = explode(':', $_SERVER['argv'][1]);
58-
if (count($split) !== 2) {
59-
die('ERROR: Only one : is allowed in first argument');
58+
if (count($split) === 1) {
59+
$this->error('CLI calls need to be like coreapi cache:clearallcaches');
60+
} elseif (count($split) !== 2) {
61+
$this->error('Only one : is allowed in first argument');
6062
}
6163

6264
$this->service = strtolower($split[0]);
@@ -80,7 +82,7 @@ public function start() {
8082
$this->siteApi();
8183
break;
8284
default:
83-
die(sprintf('ERROR: Service "%s" not supported', $this->service));
85+
$this->error(sprintf('Service "%s" not supported', $this->service));
8486
}
8587
} catch (Exception $e) {
8688
$errorMessage = sprintf('ERROR: Error in service "%s" and command "%s"": %s!', $this->service, $this->command, $e->getMessage());
@@ -106,7 +108,7 @@ protected function cacheApi() {
106108
$this->outputLine('Page cache cleared');
107109
break;
108110
default:
109-
die(sprintf('ERROR: Command "%s" not supported', $this->command));
111+
$this->error(sprintf('Command "%s" not supported', $this->command));
110112
}
111113
}
112114

@@ -123,7 +125,7 @@ protected function databaseApi() {
123125
}
124126
break;
125127
default:
126-
die(sprintf('ERROR: Command "%s" not supported', $this->command));
128+
$this->error(sprintf('Command "%s" not supported', $this->command));
127129
}
128130
}
129131

@@ -195,7 +197,7 @@ protected function extensionApi() {
195197
$this->outputTable($out);
196198
break;
197199
default:
198-
die(sprintf('ERROR: Command "%s" not supported', $this->command));
200+
$this->error(sprintf('Command "%s" not supported', $this->command));
199201
}
200202

201203
}
@@ -217,7 +219,7 @@ protected function siteApi() {
217219
$siteApiService->createSysNews($_SERVER['argv'][2], $_SERVER['argv'][3]);
218220
break;
219221
default:
220-
die(sprintf('ERROR: Command "%s" not supported', $this->command));
222+
$this->error(sprintf('Command "%s" not supported', $this->command));
221223
}
222224
}
223225

@@ -250,8 +252,17 @@ protected function outputTable(array $input) {
250252
$this->outputLine(str_repeat('-', self::MAXIMUM_LINE_LENGTH));
251253
}
252254

253-
}
255+
/**
256+
* End call
257+
*
258+
* @param string $message Error message
259+
* @return void
260+
*/
261+
protected function error($message) {
262+
die('ERROR: ' . $message);
263+
}
254264

265+
}
255266

256267
if ((TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI) && basename(PATH_thisScript) == 'cli_dispatch.phpsh') {
257268
$dispatcher = t3lib_div::makeInstance('Tx_Coreapi_Cli_Dispatcher');

Classes/Service/DatabaseApiService.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,15 @@ public function __construct() {
5454
/**
5555
* Database compare
5656
*
57-
* @param string $actions comma seperated list of IDs
57+
* @param string $actions comma separated list of IDs
5858
* @return array
59+
* @throws InvalidArgumentException
5960
*/
6061
public function databaseCompare($actions) {
6162
$errors = array();
6263

63-
64-
/** @var $service Tx_Coreapi_Service_DatabaseApiService */
65-
$service = t3lib_div::makeInstance('Tx_Coreapi_Service_DatabaseApiService');
6664
$availableActions = array_flip(t3lib_div::makeInstance('Tx_Extbase_Reflection_ClassReflection', 'Tx_Coreapi_Service_DatabaseApiService')->getConstants());
6765

68-
6966
if (empty($actions)) {
7067
throw new InvalidArgumentException('No compare modes defined');
7168
}
@@ -82,7 +79,7 @@ public function databaseCompare($actions) {
8279

8380
$tblFileContent = t3lib_div::getUrl(PATH_t3lib . 'stddb/tables.sql');
8481

85-
foreach ($GLOBALS['TYPO3_LOADED_EXT'] as $extKey => $loadedExtConf) {
82+
foreach ($GLOBALS['TYPO3_LOADED_EXT'] as $loadedExtConf) {
8683
if (is_array($loadedExtConf) && $loadedExtConf['ext_tables.sql']) {
8784
$extensionSqlContent = t3lib_div::getUrl($loadedExtConf['ext_tables.sql']);
8885
$tblFileContent .= LF . LF . LF . LF . $extensionSqlContent;

Classes/Service/ExtensionApiService.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class Tx_Coreapi_Service_ExtensionApiService {
4545
*
4646
* @param string $key extension key
4747
* @return array
48+
* @throws InvalidArgumentException
4849
*/
4950
public function getExtensionInformation($key) {
5051
if (strlen($key) === 0) {

Classes/Service/SiteApiService.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public function getSiteInfo() {
5353
* @param string $header header
5454
* @param string $text text
5555
* @return void
56+
* @throws InvalidArgumentException
5657
*/
5758
public function createSysNews($header, $text) {
5859
if (strlen($header) === 0) {

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## TYPO3 Extension 'coreapi' ##
22

3-
The EXT:coreapi should provide a simple to use API for common core features. Useable by injectable ServiceClasses or by the CLI dispatcher.
3+
The EXT:coreapi should provide a simple to use API for common core features.
44

55
Checkout the project website at forge.typo3.org:
66
http://forge.typo3.org/projects/show/extension-coreapi
@@ -15,10 +15,13 @@ Checkout the project website at forge.typo3.org:
1515
* clearConfigurationCache
1616

1717
### CLI call: ###
18+
19+
#### TYPO3 4.7+ ####
1820
If you are using TYPO3 4.7+, you can use the awesome CommandController of Extbase
1921

2022
This will show you all available calls
2123
./typo3/cli_dispatch.phpsh extbase help
2224

25+
#### TYPO3 4.6 and below ####
2326
If you are using 4.5 or 4.6, you can still use the extension with a call like
24-
./typo3/cli_dispatch.phpsh coreapi extensionapi info coreapi
27+
./typo3/cli_dispatch.phpsh coreapi cache:clearallcaches

0 commit comments

Comments
 (0)