11<?php
22
3- /* * *************************************************************
3+ /** *************************************************************
44 * Copyright notice
55 *
66 * (c) 2012 Georg Ringer <[email protected] > 2121 * GNU General Public License for more details.
2222 *
2323 * This copyright notice MUST APPEAR in all copies of the script!
24- * ************************************************************* */
24+ ***************************************************************/
2525
2626/**
2727 * Extension API Command Controller
@@ -54,12 +54,12 @@ public function infoCommand($key) {
5454
5555 $ outputInformation = array ();
5656 $ outputInformation ['is installed ' ] = ($ data ['is_installed ' ] ? 'yes ' : 'no ' );
57- foreach ($ data ['em_conf ' ] as $ emConfKey => $ emConfValue ) {
58- // Skip empty properties
57+ foreach ($ data ['em_conf ' ] as $ emConfKey => $ emConfValue ) {
58+ // Skip empty properties
5959 if (empty ($ emConfValue )) {
6060 continue ;
6161 }
62- // Skip properties which are already handled
62+ // Skip properties which are already handled
6363 if ($ emConfKey === 'title ' || $ emConfKey === 'version ' || $ emConfKey === 'state ' ) {
6464 continue ;
6565 }
@@ -72,7 +72,7 @@ public function infoCommand($key) {
7272 foreach ($ outputValue as $ additionalKey => $ additionalValue ) {
7373 if (is_array ($ additionalValue )) {
7474
75- if (empty ($ additionalValue )) {
75+ if (empty ($ additionalValue )) {
7676 continue ;
7777 }
7878 $ description .= LF . str_repeat (' ' , 28 ) . $ additionalKey ;
@@ -81,7 +81,7 @@ public function infoCommand($key) {
8181 $ description .= str_repeat (' ' , 30 ) . $ ak . ': ' . $ av . LF ;
8282 }
8383 } else {
84- $ description .= LF . str_repeat (' ' , 28 ) . $ additionalKey . ': ' . $ additionalValue ;
84+ $ description .= LF . str_repeat (' ' , 28 ) . $ additionalKey . ': ' . $ additionalValue ;
8585 }
8686 }
8787 } else {
@@ -131,6 +131,141 @@ public function updateListCommand() {
131131 $ this ->outputLine ('Extension list has been updated. ' );
132132 }
133133
134+ /**
135+ * Install(activate) an extension
136+ *
137+ * @param string $key extension key
138+ * @return void
139+ */
140+ public function installCommand ($ key ) {
141+ try {
142+ /** @var $service Tx_Coreapi_Service_ExtensionApiService */
143+ $ service = $ this ->objectManager ->get ('Tx_Coreapi_Service_ExtensionApiService ' );
144+ $ data = $ service ->installExtension ($ key );
145+ } catch (Exception $ e ) {
146+ $ this ->outputLine ($ e ->getMessage ());
147+ $ this ->quit ();
148+ }
149+ $ this ->outputLine (sprintf ('Extension "%s" is now installed! ' , $ key ));
150+ }
151+
152+ /**
153+ * UnInstall(deactivate) an extension
154+ *
155+ * @param string $key extension key
156+ * @return void
157+ */
158+ public function uninstallCommand ($ key ) {
159+ try {
160+ /** @var $service Tx_Coreapi_Service_ExtensionApiService */
161+ $ service = $ this ->objectManager ->get ('Tx_Coreapi_Service_ExtensionApiService ' );
162+ $ data = $ service ->uninstallExtension ($ key );
163+ } catch (Exception $ e ) {
164+ $ this ->outputLine ($ e ->getMessage ());
165+ $ this ->quit ();
166+ }
167+ $ this ->outputLine (sprintf ('Extension "%s" is now uninstalled! ' , $ key ));
168+ }
169+
170+ /**
171+ * Configure an extension
172+ *
173+ * This command enables you to configure an extension.
174+ *
175+ * examples:
176+ *
177+ * [1] Using a standard formatted ini-file
178+ * ./cli_dispatch.phpsh extbase extensionapi:configure rtehtmlarea --configfile=C:\rteconf.txt
179+ *
180+ * [2] Adding configuration settings directly on the command line
181+ * ./cli_dispatch.phpsh extbase extensionapi:configure rtehtmlarea --settings="enableImages=1;allowStyleAttribute=0"
182+ *
183+ * [3] A combination of [1] and [2]
184+ * ./cli_dispatch.phpsh extbase extensionapi:configure rtehtmlarea --configfile=C:\rteconf.txt --settings="enableImages=1;allowStyleAttribute=0"
185+ *
186+ * @param string $key extension key
187+ * @param string $configfile path to file containing configuration settings. Must be formatted as a standard ini-file
188+ * @param string $settings string containing configuration settings separated on the form "k1=v1;k2=v2;"
189+ * @return void
190+ */
191+ public function configureCommand ($ key , $ configfile = '' , $ settings = '' ) {
192+ global $ TYPO3_CONF_VARS ;
193+ try {
194+ /** @var $service Tx_Coreapi_Service_ExtensionApiService */
195+ $ service = $ this ->objectManager ->get ('Tx_Coreapi_Service_ExtensionApiService ' );
196+ $ conf = array ();
197+ if (is_file ($ configfile )) {
198+ $ conf = parse_ini_file ($ configfile );
199+ }
200+
201+ if (strlen ($ settings )) {
202+ $ arr = explode ('; ' , $ settings );
203+ foreach ($ arr as $ v ) {
204+ if (strpos ($ v , '= ' ) === FALSE ) {
205+ throw new InvalidArgumentException (sprintf ('Ill-formed setting "%s"! ' , $ v ));
206+ }
207+ $ parts = t3lib_div::trimExplode ('= ' , $ v , FALSE , 2 );
208+ if (!empty ($ parts [0 ])) {
209+ $ conf [$ parts [0 ]] = $ parts [1 ];
210+ }
211+ }
212+ }
213+
214+ if (empty ($ conf )) {
215+ throw new InvalidArgumentException (sprintf ('No configuration settings! ' , $ key ));
216+ }
217+ $ data = $ service ->configureExtension ($ key , $ conf );
218+
219+ } catch (Exception $ e ) {
220+ $ this ->outputLine ($ e ->getMessage ());
221+ $ this ->quit ();
222+ }
223+ $ this ->outputLine (sprintf ('Extension "%s" has been configured! ' , $ key ));
224+ }
225+
226+ /**
227+ * Fetch an extension from TER
228+ *
229+ * @param string $key extension key
230+ * @param string $version the exact version of the extension, otherwise the latest will be picked
231+ * @param string $location where to put the extension. S = typo3/sysext, G = typo3/ext, L = typo3conf/ext
232+ * @param bool $overwrite overwrite the extension if it already exists
233+ * @param string $mirror mirror to fetch the extension from, otherwise a random mirror will be selected
234+ * @return void
235+ */
236+ public function fetchCommand ($ key , $ version = '' , $ location = 'L ' , $ overwrite = FALSE , $ mirror = '' ) {
237+ try {
238+ /** @var $service Tx_Coreapi_Service_ExtensionApiService */
239+ $ service = $ this ->objectManager ->get ('Tx_Coreapi_Service_ExtensionApiService ' );
240+ $ data = $ service ->fetchExtension ($ key , $ version , $ location , $ overwrite , $ mirror );
241+ $ this ->outputLine (sprintf ('Extension "%s" version %s has been fetched from repository! ' , $ data ['extKey ' ], $ data ['version ' ]));
242+ } catch (Exception $ e ) {
243+ $ this ->outputLine ($ e ->getMessage ());
244+ $ this ->quit ();
245+ }
246+ }
247+
248+ /**
249+ * Import extension from file
250+ *
251+ * @param string $file path to t3x file
252+ * @param string $location where to import the extension. S = typo3/sysext, G = typo3/ext, L = typo3conf/ext
253+ * @param boolean $overwrite overwrite the extension if it already exists
254+ * @return void
255+ */
256+ public function importCommand ($ file , $ location = 'L ' , $ overwrite = FALSE ) {
257+ try {
258+ /** @var $service Tx_Coreapi_Service_ExtensionApiService */
259+ $ service = $ this ->objectManager ->get ('Tx_Coreapi_Service_ExtensionApiService ' );
260+ $ data = $ service ->importExtension ($ file , $ location , $ overwrite );
261+ $ this ->outputLine (sprintf ('Extension "%s" has been imported! ' , $ data ['extKey ' ]));
262+
263+ } catch (Exception $ e ) {
264+ $ this ->outputLine ($ e ->getMessage ());
265+ $ this ->quit ();
266+ }
267+ }
268+
134269 /**
135270 * createUploadFoldersCommand
136271 *
@@ -149,7 +284,6 @@ public function createUploadFoldersCommand() {
149284 $ this ->outputLine ('no uploadFolder created ' );
150285 }
151286 }
152-
153287}
154288
155289?>
0 commit comments