@@ -103,6 +103,10 @@ public function start() {
103103 }
104104 }
105105
106+ /**
107+ * @param $command
108+ * @throws InvalidArgumentException
109+ */
106110 protected function runCommand ($ command ) {
107111 if (method_exists ($ this , $ command )) {
108112 $ args = array_slice ($ this ->cli_args ['_DEFAULT ' ], 2 );
@@ -139,8 +143,7 @@ protected function runCommand($command) {
139143 * @example ./cli_dispatch.phpsh coreapi cache:clearallcaches
140144 */
141145 public function cacheClearallcachesCommand () {
142- $ cacheApiService = t3lib_div::makeInstance ('Tx_Coreapi_Service_CacheApiService ' );
143- $ cacheApiService ->initializeObject ();
146+ $ cacheApiService = $ this ->getCacheApiService ();
144147 $ cacheApiService ->clearAllCaches ();
145148 $ this ->outputLine ('All caches cleared ' );
146149 }
@@ -155,8 +158,7 @@ public function cacheClearallcachesCommand() {
155158 * @example ./cli_dispatch.phpsh coreapi cache:clearconfigurationcache
156159 */
157160 public function cacheClearconfigurationcacheCommand () {
158- $ cacheApiService = t3lib_div::makeInstance ('Tx_Coreapi_Service_CacheApiService ' );
159- $ cacheApiService ->initializeObject ();
161+ $ cacheApiService = $ this ->getCacheApiService ();
160162 $ cacheApiService ->clearConfigurationCache ();
161163 $ this ->outputLine ('Configuration cache cleared ' );
162164 }
@@ -170,8 +172,7 @@ public function cacheClearconfigurationcacheCommand() {
170172 * @example ./cli_dispatch.phpsh coreapi cache:clearpagecache
171173 */
172174 public function cacheClearpagecacheCommand () {
173- $ cacheApiService = t3lib_div::makeInstance ('Tx_Coreapi_Service_CacheApiService ' );
174- $ cacheApiService ->initializeObject ();
175+ $ cacheApiService = $ this ->getCacheApiService ();
175176 $ cacheApiService ->clearPageCache ();
176177 $ this ->outputLine ('Page cache cleared ' );
177178 }
@@ -186,7 +187,7 @@ public function cacheClearpagecacheCommand() {
186187 * @example ./cli_dispatch.phpsh coreapi database:databasecompare 2
187188 */
188189 public function databaseDatabasecompareCommand ($ actions ) {
189- $ databaseApiService = t3lib_div:: makeInstance ( ' Tx_Coreapi_Service_DatabaseApiService ' );
190+ $ databaseApiService = $ this -> getDatabaseApiService ( );
190191 if ($ actions === 'help ' ) {
191192 $ actions = $ databaseApiService ->databaseCompareAvailableActions ();
192193 $ this ->outputTable ($ actions );
@@ -205,7 +206,7 @@ public function databaseDatabasecompareCommand($actions) {
205206 * @example ./cli_dispatch.phpsh coreapi extension:info rtehtmlarea
206207 */
207208 public function extensionInfoCommand ($ extkey ) {
208- $ extensionApiService = t3lib_div:: makeInstance ( ' Tx_Coreapi_Service_ExtensionApiService ' );
209+ $ extensionApiService = $ this -> getExtensionApiService ( );
209210 $ data = $ extensionApiService ->getExtensionInformation ($ extkey );
210211 $ this ->outputLine ('' );
211212 $ this ->outputLine ('EXTENSION "%s": %s %s ' , array (strtoupper ($ extkey ), $ data ['em_conf ' ]['version ' ], $ data ['em_conf ' ]['state ' ]));
@@ -259,7 +260,7 @@ public function extensionInfoCommand($extkey) {
259260 * @example ./cli_dispatch.phpsh coreapi extension:updatelist
260261 */
261262 public function extensionUpdatelistCommand () {
262- $ extensionApiService = t3lib_div:: makeInstance ( ' Tx_Coreapi_Service_ExtensionApiService ' );
263+ $ extensionApiService = $ this -> getExtensionApiService ( );
263264 $ extensionApiService ->updateMirrors ();
264265 $ this ->outputLine ('Extension list has been updated. ' );
265266 }
@@ -272,7 +273,7 @@ public function extensionUpdatelistCommand() {
272273 * @example ./cli_dispatch.phpsh coreapi extension:listinstalled --type=S
273274 */
274275 public function extensionListinstalledCommand ($ type = '' ) {
275- $ extensionApiService = t3lib_div:: makeInstance ( ' Tx_Coreapi_Service_ExtensionApiService ' );
276+ $ extensionApiService = $ this -> getExtensionApiService ( );
276277 $ extensions = $ extensionApiService ->getInstalledExtensions ($ type );
277278 $ out = array ();
278279
@@ -290,8 +291,8 @@ public function extensionListinstalledCommand($type = '') {
290291 * @return void
291292 */
292293 public function extensionInstallCommand ($ key ) {
293- $ service = t3lib_div:: makeInstance ( ' Tx_Coreapi_Service_ExtensionApiService ' );
294- $ data = $ service ->installExtension ($ key );
294+ $ extensionApiService = $ this -> getExtensionApiService ( );
295+ $ data = $ extensionApiService ->installExtension ($ key );
295296 $ this ->outputLine (sprintf ('Extension "%s" is now installed! ' , $ key ));
296297 }
297298
@@ -302,8 +303,8 @@ public function extensionInstallCommand($key) {
302303 * @return void
303304 */
304305 public function extensionUninstallCommand ($ key ) {
305- $ service = t3lib_div:: makeInstance ( ' Tx_Coreapi_Service_ExtensionApiService ' );
306- $ data = $ service ->unInstallExtension ($ key );
306+ $ extensionApiService = $ this -> getExtensionApiService ( );
307+ $ data = $ extensionApiService ->unInstallExtension ($ key );
307308 $ this ->outputLine (sprintf ('Extension "%s" is now uninstalled! ' , $ key ));
308309 }
309310
@@ -331,7 +332,7 @@ public function extensionUninstallCommand($key) {
331332 */
332333 public function extensionConfigureCommand ($ key , $ configfile = '' , $ settings = '' ) {
333334 global $ TYPO3_CONF_VARS ;
334- $ service = t3lib_div:: makeInstance ( ' Tx_Coreapi_Service_ExtensionApiService ' );
335+ $ extensionApiService = $ this -> getExtensionApiService ( );
335336 $ conf = array ();
336337
337338 if (is_file ($ configfile )) {
@@ -356,7 +357,7 @@ public function extensionConfigureCommand($key, $configfile = '', $settings = ''
356357 throw new InvalidArgumentException (sprintf ('No configuration settings! ' , $ key ));
357358 }
358359
359- $ service ->configureExtension ($ key , $ conf );
360+ $ extensionApiService ->configureExtension ($ key , $ conf );
360361 $ this ->outputLine (sprintf ('Extension "%s" has been configured! ' , $ key ));
361362
362363 }
@@ -373,8 +374,8 @@ public function extensionConfigureCommand($key, $configfile = '', $settings = ''
373374 * @return void
374375 */
375376 public function extensionFetchCommand ($ key , $ version = '' , $ location = 'L ' , $ overwrite = FALSE , $ mirror = '' ) {
376- $ service = t3lib_div:: makeInstance ( ' Tx_Coreapi_Service_ExtensionApiService ' );
377- $ data = $ service ->fetchExtension ($ key , $ version , $ location , $ overwrite , $ mirror );
377+ $ extensionApiService = $ this -> getExtensionApiService ( );
378+ $ data = $ extensionApiService ->fetchExtension ($ key , $ version , $ location , $ overwrite , $ mirror );
378379 $ this ->outputLine (sprintf ('Extension "%s" version %s has been fetched from repository! ' , $ data ['extKey ' ], $ data ['version ' ]));
379380 }
380381
@@ -388,8 +389,8 @@ public function extensionFetchCommand($key, $version = '', $location = 'L', $ove
388389 * @return void
389390 */
390391 public function extensionImportCommand ($ file , $ location = 'L ' , $ overwrite = FALSE ) {
391- $ service = t3lib_div:: makeInstance ( ' Tx_Coreapi_Service_ExtensionApiService ' );
392- $ data = $ service ->importExtension ($ file , $ location , $ overwrite );
392+ $ extensionApiService = $ this -> getExtensionApiService ( );
393+ $ data = $ extensionApiService ->importExtension ($ file , $ location , $ overwrite );
393394 $ this ->outputLine (sprintf ('Extension "%s" has been imported! ' , $ data ['extKey ' ]));
394395 }
395396
@@ -398,8 +399,8 @@ public function extensionImportCommand($file, $location = 'L', $overwrite = FALS
398399 * @return void
399400 */
400401 public function extensionCreateuploadfoldersCommand () {
401- $ service = t3lib_div:: makeInstance ( ' Tx_Coreapi_Service_ExtensionApiService ' );
402- $ messages = $ service ->createUploadFolders ();
402+ $ extensionApiService = $ this -> getExtensionApiService ( );
403+ $ messages = $ extensionApiService ->createUploadFolders ();
403404 if (sizeof ($ messages )) {
404405 foreach ($ messages as $ message ) {
405406 $ this ->outputLine ($ message );
@@ -418,7 +419,7 @@ public function extensionCreateuploadfoldersCommand() {
418419 * @example ./cli_dispatch.phpsh coreapi site:info
419420 */
420421 public function siteInfoCommand () {
421- $ siteApiService = t3lib_div:: makeInstance ( ' Tx_Coreapi_Service_SiteApiService ' );
422+ $ siteApiService = $ this -> getSiteApiService ( );
422423 $ infos = $ siteApiService ->getSiteInfo ();
423424 $ this ->outputTable ($ infos );
424425 }
@@ -434,7 +435,7 @@ public function siteInfoCommand() {
434435 * @example ./cli_dispatch.phpsh coreapi site:createsysnews "The header" "The news text"
435436 */
436437 public function siteCreatesysnewsCommand ($ header , $ text ) {
437- $ siteApiService = t3lib_div:: makeInstance ( ' Tx_Coreapi_Service_SiteApiService ' );
438+ $ siteApiService = $ this -> getSiteApiService ( );
438439 $ siteApiService ->createSysNews ($ header , $ text );
439440 }
440441
@@ -511,11 +512,11 @@ public function cli_help() {
511512 */
512513 protected function setHelpFromDocComment ($ operation ) {
513514 list ($ service , $ command ) = explode (': ' , $ operation , 2 );
514- $ commandmethod = strtolower ($ service ) . ucfirst ($ command ) . 'Command ' ;
515- if (method_exists ($ this , $ commandmethod )) {
515+ $ commandMethod = strtolower ($ service ) . ucfirst ($ command ) . 'Command ' ;
516+ if (method_exists ($ this , $ commandMethod )) {
516517 $ this ->cli_help ['options ' ] = '' ;
517518 //extract doc comment
518- $ ref = new ReflectionMethod (get_class ($ this ), $ commandmethod );
519+ $ ref = new ReflectionMethod (get_class ($ this ), $ commandMethod );
519520 $ comment = $ ref ->getDocComment ();
520521 $ comment = preg_replace ('/\/\*\*\s*(.*)\s*\*\//s ' , '$1 ' , $ comment );
521522 $ lines = explode (PHP_EOL , $ comment );
@@ -596,6 +597,39 @@ protected function setHelpFromDocComment($operation) {
596597 $ this ->error (sprintf ('No help available for "%s" ' , $ operation ) . PHP_EOL );
597598 }
598599 }
600+
601+ /**
602+ * @return Tx_Coreapi_Service_CacheApiService
603+ */
604+ protected function getCacheApiService () {
605+ $ cacheApiService = t3lib_div::makeInstance ('Tx_Coreapi_Service_CacheApiService ' );
606+ $ cacheApiService ->initializeObject ();
607+ return $ cacheApiService ;
608+ }
609+
610+ /**
611+ * @return Tx_Coreapi_Service_DatabaseApiService
612+ */
613+ protected function getDatabaseApiService () {
614+ $ databaseApiService = t3lib_div::makeInstance ('Tx_Coreapi_Service_DatabaseApiService ' );
615+ return $ databaseApiService ;
616+ }
617+
618+ /**
619+ * @return Tx_Coreapi_Service_ExtensionApiService
620+ */
621+ protected function getExtensionApiService () {
622+ $ extensionApiService = t3lib_div::makeInstance ('Tx_Coreapi_Service_ExtensionApiService ' );
623+ return $ extensionApiService ;
624+ }
625+
626+ /**
627+ * @return Tx_Coreapi_Service_SiteApiService
628+ */
629+ protected function getSiteApiService () {
630+ $ siteApiService = t3lib_div::makeInstance ('Tx_Coreapi_Service_SiteApiService ' );
631+ return $ siteApiService ;
632+ }
599633}
600634
601635if ((TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI ) && basename (PATH_thisScript) == 'cli_dispatch.phpsh ' ) {
0 commit comments