diff --git a/Classes/Command/BackendApiCommandController.php b/Classes/Command/BackendApiCommandController.php new file mode 100644 index 0000000..c250c18 --- /dev/null +++ b/Classes/Command/BackendApiCommandController.php @@ -0,0 +1,110 @@ + + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * A copy is found in the text file GPL.txt and important notices to the license + * from the author is found in LICENSE.txt distributed with these scripts. + * + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ +use TYPO3\CMS\Extbase\Mvc\Controller\CommandController; + +/** + * API Command Controller + */ +class BackendApiCommandController extends CommandController { + + /** + * @var \TYPO3\CMS\Core\Log\LogManager $logManager + */ + protected $logManager; + + /** + * @var \TYPO3\CMS\Core\Log\Logger $logger + */ + protected $logger; + + /** + * @param \TYPO3\CMS\Core\Log\LogManager $logManager + * + * @return void + */ + public function injectLogManager(\TYPO3\CMS\Core\Log\LogManager $logManager) { + $this->logManager = $logManager; + } + + /** + * Initialize the object + */ + public function initializeObject() { + $this->logger = $this->objectManager->get('\TYPO3\CMS\Core\Log\LogManager')->getLogger(__CLASS__); + } + + /** + * Locks backend access for all users by writing a lock file that is checked when the backend is accessed. + * + * @param string $redirectUrl URL to redirect to when the backend is accessed + */ + public function lockCommand($redirectUrl = NULL) { + if (@is_file((PATH_typo3conf . 'LOCK_BACKEND'))) { + $message = 'A lockfile already exists. Overwriting it...'; + $this->outputLine($message); + $this->logger->info($message); + } + + \TYPO3\CMS\Core\Utility\GeneralUtility::writeFile(PATH_typo3conf . 'LOCK_BACKEND', (string)$redirectUrl); + + if ($redirectUrl === NULL) { + $message = 'Wrote lock file to \'typo3conf/LOCK_BACKEND\''; + $this->outputLine($message); + $this->logger->info($message); + } else { + $message = 'Wrote lock file to \'typo3conf/LOCK_BACKEND\' with instruction to redirect to: \'' . $redirectUrl . '\''; + $this->outputLine($message); + $this->logger->info($message); + } + } + + /** + * Unlocks the backend access by deleting the lock file + */ + public function unlockCommand() { + if (@is_file((PATH_typo3conf . 'LOCK_BACKEND'))) { + unlink(PATH_typo3conf . 'LOCK_BACKEND'); + if (@is_file((PATH_typo3conf . 'LOCK_BACKEND'))) { + $message = 'ERROR: Could not remove lock file \'typo3conf/LOCK_BACKEND\'!'; + $this->outputLine($message); + $this->logger->error($message); + $this->quit(1); + } else { + $message = 'Removed lock file \'typo3conf/LOCK_BACKEND\''; + $this->outputLine($message); + $this->logger->info($message); + } + } else { + $message = 'No lock file \'typo3conf/LOCK_BACKEND\' was found, hence no lock could be removed.'; + $this->outputLine($message); + $this->logger->info($message); + $this->quit(1); + } + } +} \ No newline at end of file diff --git a/Classes/Command/CacheApiCommandController.php b/Classes/Command/CacheApiCommandController.php index eb9b941..167858f 100644 --- a/Classes/Command/CacheApiCommandController.php +++ b/Classes/Command/CacheApiCommandController.php @@ -34,6 +34,31 @@ * @package Etobi\CoreAPI\Service\SiteApiService */ class CacheApiCommandController extends CommandController { + /** + * @var \TYPO3\CMS\Core\Log\LogManager $logManager + */ + protected $logManager; + + /** + * @var \TYPO3\CMS\Core\Log\Logger $logger + */ + protected $logger; + + /** + * @param \TYPO3\CMS\Core\Log\LogManager $logManager + * + * @return void + */ + public function injectLogManager(\TYPO3\CMS\Core\Log\LogManager $logManager) { + $this->logManager = $logManager; + } + + /** + * Initialize the object + */ + public function initializeObject() { + $this->logger = $this->objectManager->get('\TYPO3\CMS\Core\Log\LogManager')->getLogger(__CLASS__); + } /** * @var \Etobi\CoreAPI\Service\CacheApiService @@ -51,12 +76,50 @@ public function injectCacheApiService(\Etobi\CoreAPI\Service\CacheApiService $ca /** * Clear all caches. + * If hard, cache will be cleared in a more straightforward approach and the according backend hooks are not executed. * + * @param boolean $hard * @return void */ - public function clearAllCachesCommand() { - $this->cacheApiService->clearAllCaches(); - $this->outputLine('All caches have been cleared.'); + public function clearAllCachesCommand($hard = false) { + $this->cacheApiService->clearAllCaches($hard); + $message = 'All caches have been cleared%s.'; + $this->logger->info($message); + $this->outputLine($message, $hard ? array(' hard') : array('')); + } + + /** + * Clear system cache. + * + * @return void + */ + public function clearSystemCacheCommand() { + $this->cacheApiService->clearSystemCache(); + $message = 'System cache has been cleared'; + $this->logger->info($message); + $this->outputLine($message); + } + + /** + * Clears the opcode cache. + * + * @param string|NULL $fileAbsPath The file as absolute path to be cleared + * or NULL to clear completely. + * + * @return void + */ + public function clearAllActiveOpcodeCacheCommand($fileAbsPath = NULL) { + $this->cacheApiService->clearAllActiveOpcodeCache($fileAbsPath); + + if ($fileAbsPath !== NULL) { + $message = sprintf('The opcode cache for the file %s has been cleared', $fileAbsPath); + $this->outputLine($message); + $this->logger->info($message); + } else { + $message = 'The complete opcode cache has been cleared'; + $this->outputLine($message); + $this->logger->info($message); + } } /** @@ -66,7 +129,9 @@ public function clearAllCachesCommand() { */ public function clearConfigurationCacheCommand() { $this->cacheApiService->clearConfigurationCache(); - $this->outputLine('Configuration cache has been cleared.'); + $message = 'Configuration cache has been cleared.'; + $this->logger->info($message); + $this->outputLine($message); } /** @@ -76,7 +141,9 @@ public function clearConfigurationCacheCommand() { */ public function clearPageCacheCommand() { $this->cacheApiService->clearPageCache(); - $this->outputLine('Page cache has been cleared.'); + $message = 'Page cache has been cleared.'; + $this->logger->info($message); + $this->outputLine($message); } /** @@ -87,6 +154,8 @@ public function clearPageCacheCommand() { */ public function clearAllExceptPageCacheCommand() { $clearedCaches = $this->cacheApiService->clearAllExceptPageCache(); - $this->outputLine('Cleared caches: ' . implode(', ', $clearedCaches)); + $message = 'Cleared caches: ' . implode(', ', $clearedCaches); + $this->logger->info($message); + $this->outputLine($message); } -} +} \ No newline at end of file diff --git a/Classes/Command/DatabaseApiCommandController.php b/Classes/Command/DatabaseApiCommandController.php index 6777cb5..b60444e 100644 --- a/Classes/Command/DatabaseApiCommandController.php +++ b/Classes/Command/DatabaseApiCommandController.php @@ -35,38 +35,91 @@ */ class DatabaseApiCommandController extends CommandController { + /** + * @var \TYPO3\CMS\Core\Log\LogManager $logManager + */ + protected $logManager; + + /** + * @var \TYPO3\CMS\Core\Log\Logger $logger + */ + protected $logger; + + /** + * @param \TYPO3\CMS\Core\Log\LogManager $logManager + * + * @return void + */ + public function injectLogManager(\TYPO3\CMS\Core\Log\LogManager $logManager) { + $this->logManager = $logManager; + } + + /** + * Initialize the object + */ + public function initializeObject() { + $this->logger = $this->objectManager->get('\TYPO3\CMS\Core\Log\LogManager')->getLogger(__CLASS__); + } + + /** + * @var \Etobi\CoreAPI\Service\DatabaseApiService $databaseApiService + */ + protected $databaseApiService; + + /** + * Injects the DatabaseApiService object + * + * @param \Etobi\CoreAPI\Service\DatabaseApiService $databaseApiService + * + * @return void + */ + public function injectDatabaseApiService(\Etobi\CoreAPI\Service\DatabaseApiService $databaseApiService) { + $this->databaseApiService = $databaseApiService; + } + /** * Database compare. * Leave the argument 'actions' empty or use "help" to see the available ones * * @param string $actions List of actions which will be executed + * @param bool $dry */ - public function databaseCompareCommand($actions = '') { - $service = $this->getService(); - + public function databaseCompareCommand($actions = '', $dry = FALSE) { if ($actions === 'help' || strlen($actions) === 0) { - $actions = $service->databaseCompareAvailableActions(); + $actions = $this->databaseApiService->databaseCompareAvailableActions(); foreach ($actions as $number => $action) { $this->outputLine(' - ' . $action . ' => ' . $number); } $this->quit(); } - $result = $service->databaseCompare($actions); - if (empty($result)) { - $this->outputLine('DB has been compared'); + $result = $this->databaseApiService->databaseCompare($actions, $dry); + + if ($dry) { + $this->outputLine('DB compare would execute the following queries:'); + foreach($result as $key => $set) { + $this->outputLine(sprintf('### Action: %s ###', $key)); + $this->outputLine('==================================='); + $this->logger->info(sprintf('### Action: %s ###', $key)); + $this->logger->info('==================================='); + foreach($set as $line) { + $this->outputLine($line); + $this->logger->info($line); + } + $this->outputLine(LF); + } + $this->logger->info('DB compare executed in dry mode'); } else { - $this->outputLine('DB could not be compared, Error(s): %s', array(LF . implode(LF, $result))); - $this->quit(); + if (empty($result)) { + $message = 'DB has been compared'; + $this->outputLine($message); + $this->logger->info($message); + } else { + $message = sprintf('DB could not be compared, Error(s): %s', array(LF . implode(LF, $result))); + $this->outputLine($message); + $this->logger->error($message); + $this->quit(1); + } } } - - /** - * Returns the service object. - * - * @return \Etobi\CoreAPI\Service\DatabaseApiService object - */ - private function getService() { - return $this->objectManager->get('Etobi\\CoreAPI\\Service\\DatabaseApiService'); - } } \ No newline at end of file diff --git a/Classes/Command/ExtensionApiCommandController.php b/Classes/Command/ExtensionApiCommandController.php index 3cd40af..91e998e 100644 --- a/Classes/Command/ExtensionApiCommandController.php +++ b/Classes/Command/ExtensionApiCommandController.php @@ -38,6 +38,32 @@ */ class ExtensionApiCommandController extends CommandController { + /** + * @var \TYPO3\CMS\Core\Log\LogManager $logManager + */ + protected $logManager; + + /** + * @var \TYPO3\CMS\Core\Log\Logger $logger + */ + protected $logger; + + /** + * @param \TYPO3\CMS\Core\Log\LogManager $logManager + * + * @return void + */ + public function injectLogManager(\TYPO3\CMS\Core\Log\LogManager $logManager) { + $this->logManager = $logManager; + } + + /** + * Initialize the object + */ + public function initializeObject() { + $this->logger = $this->objectManager->get('\TYPO3\CMS\Core\Log\LogManager')->getLogger(__CLASS__); + } + /** * @var \Etobi\CoreAPI\Service\ExtensionApiService * @inject @@ -62,8 +88,10 @@ public function infoCommand($key) { try { $data = $this->extensionApiService->getExtensionInformation($key); } catch (Exception $e) { - $this->outputLine($e->getMessage()); - $this->quit(); + $message = $e->getMessage(); + $this->outputLine($message); + $this->logger->error($message); + $this->quit(1); } $this->outputLine(''); @@ -107,6 +135,8 @@ public function infoCommand($key) { } $this->outputLine('%-2s%-25s %s', array(' ', $outputKey, $description)); } + + $this->logger->info('extensionApi:info executes successfully.'); } /** @@ -120,8 +150,11 @@ public function infoCommand($key) { public function listInstalledCommand($type = '') { $type = ucfirst(strtolower($type)); if (!empty($type) && $type !== 'Local' && $type !== 'Global' && $type !== 'System') { - $this->outputLine('Only "Local", "System" and "Global" are supported as type (or nothing)'); - $this->quit(); + // TODO: Throw a exception here? + $message = 'Only "Local", "System" and "Global" are supported as type (or nothing)'; + $this->outputLine($message); + $this->logger->error($message); + $this->quit(1); } $extensions = $this->extensionApiService->listExtensions($type); @@ -135,6 +168,7 @@ public function listInstalledCommand($type = '') { $this->outputLine('%-2s%-40s', array(' ', str_repeat('-', self::MAXIMUM_LINE_LENGTH - 3))); $this->outputLine(' Total: ' . count($extensions) . ' extensions'); + $this->logger->info('extensionApi:listInstalled executed successfully'); } /** @@ -147,9 +181,13 @@ public function updateListCommand() { $result = $this->extensionApiService->updateMirrors(); if ($result) { - $this->outputLine('Extension list has been updated.'); + $message = 'Extension list has been updated.'; + $this->outputLine($message); + $this->logger->info($message); } else { - $this->outputLine('Extension list already up-to-date.'); + $message = 'Extension list already up-to-date.'; + $this->outputLine($message); + $this->logger->info($message); } } @@ -165,10 +203,15 @@ public function installCommand($key) { $this->emitPackagesMayHaveChangedSignal(); $this->extensionApiService->installExtension($key); } catch (Exception $e) { - $this->outputLine($e->getMessage()); - $this->quit(); + $message = $e->getMessage(); + $this->outputLine($message); + $this->logger->error($message); + $this->quit(1); } - $this->outputLine(sprintf('Extension "%s" is now installed!', $key)); + + $message = sprintf('Extension "%s" is now installed!', $key); + $this->outputLine($message); + $this->logger->info($message); } /** @@ -182,10 +225,15 @@ public function uninstallCommand($key) { try { $this->extensionApiService->uninstallExtension($key); } catch (Exception $e) { - $this->outputLine($e->getMessage()); - $this->quit(); + $message = $e->getMessage(); + $this->outputLine($message); + $this->logger->error($message); + $this->quit(1); } - $this->outputLine(sprintf('Extension "%s" is now uninstalled!', $key)); + + $message = sprintf('Extension "%s" is now uninstalled!', $key); + $this->outputLine($message); + $this->logger->info($message); } /** @@ -230,16 +278,24 @@ public function configureCommand($key, $configFile = '', $settings = '') { } if (empty($conf)) { - throw new InvalidArgumentException(sprintf('No configuration settings!', $key)); + $this->response->setExitCode(1); + $message = sprintf('No configuration settings!', $key); + $this->logger->error($message); + throw new InvalidArgumentException($message); } $this->extensionApiService->configureExtension($key, $conf); } catch (Exception $e) { - $this->outputLine($e->getMessage()); - $this->quit(); + $message = $e->getMessage(); + $this->outputLine($message); + $this->logger->error($message); + $this->quit(1); } - $this->outputLine(sprintf('Extension "%s" has been configured!', $key)); + + $message = sprintf('Extension "%s" has been configured!', $key); + $this->outputLine($message); + $this->logger->info($message); } /** @@ -256,10 +312,14 @@ public function configureCommand($key, $configFile = '', $settings = '') { public function fetchCommand($key, $version = '', $location = 'Local', $overwrite = FALSE, $mirror = -1) { try { $data = $this->extensionApiService->fetchExtension($key, $version, $location, $overwrite, $mirror); - $this->outputLine(sprintf('Extension "%s" version %s has been fetched from repository! Dependencies were not resolved.', $data['main']['extKey'], $data['main']['version'])); + $message = sprintf('Extension "%s" version %s has been fetched from repository! Dependencies were not resolved.', $data['main']['extKey'], $data['main']['version']); + $this->outputLine($message); + $this->logger->info($message); } catch (Exception $e) { - $this->outputLine($e->getMessage()); - $this->quit(); + $message = $e->getMessage(); + $this->outputLine($message); + $this->logger->error($message); + $this->quit(1); } } @@ -277,9 +337,12 @@ public function listMirrorsCommand() { ++$key; } } catch (Exception $e) { - $this->outputLine($e->getMessage()); - $this->quit(); + $message = $e->getMessage(); + $this->outputLine($message); + $this->logger->error($message); + $this->quit(1); } + $this->logger->info('extensionApi:listMirrors executed successfully.'); } /** @@ -294,10 +357,13 @@ public function listMirrorsCommand() { public function importCommand($file, $location = 'Local', $overwrite = FALSE) { try { $data = $this->extensionApiService->importExtension($file, $location, $overwrite); - $this->outputLine(sprintf('Extension "%s" has been imported!', $data['extKey'])); + $message = sprintf('Extension "%s" has been imported!', $data['extKey']); + $this->outputLine($message); + $this->logger->info($message); } catch (Exception $e) { $this->outputLine($e->getMessage()); - $this->quit(); + $this->logger->error($e->getMessage()); + $this->quit(1); } } diff --git a/Classes/Command/SiteApiCommandController.php b/Classes/Command/SiteApiCommandController.php index 9daa197..715841e 100644 --- a/Classes/Command/SiteApiCommandController.php +++ b/Classes/Command/SiteApiCommandController.php @@ -36,6 +36,32 @@ */ class SiteApiCommandController extends CommandController { + /** + * @var \TYPO3\CMS\Core\Log\LogManager $logManager + */ + protected $logManager; + + /** + * @var \TYPO3\CMS\Core\Log\Logger $logger + */ + protected $logger; + + /** + * @param \TYPO3\CMS\Core\Log\LogManager $logManager + * + * @return void + */ + public function injectLogManager(\TYPO3\CMS\Core\Log\LogManager $logManager) { + $this->logManager = $logManager; + } + + /** + * Initialize the object + */ + public function initializeObject() { + $this->logger = $this->objectManager->get('\TYPO3\CMS\Core\Log\LogManager')->getLogger(__CLASS__); + } + /** * @var \Etobi\CoreAPI\Service\SiteApiService */ @@ -64,6 +90,8 @@ public function infoCommand() { $line = wordwrap($value, self::MAXIMUM_LINE_LENGTH - 43, PHP_EOL . str_repeat(' ', 43), TRUE); $this->outputLine('%-2s%-40s %s', array(' ', $key, $line)); } + + $this->logger->info('siteApi:info executes successfully.'); } /** @@ -81,13 +109,14 @@ public function createSysNewsCommand($header, $text = '') { $result = $this->siteApiService->createSysNews($header, $text); } catch (\Exception $e) { $this->outputLine($e->getMessage()); - $this->quit(); + $this->quit(1); } if ($result) { $this->outputLine('News entry successfully created.'); } else { $this->outputLine('News entry NOT created.'); + $this->quit(1); } } } diff --git a/Classes/Service/CacheApiService.php b/Classes/Service/CacheApiService.php index ff27b98..4607a2c 100644 --- a/Classes/Service/CacheApiService.php +++ b/Classes/Service/CacheApiService.php @@ -47,6 +47,11 @@ class CacheApiService { */ protected $objectManager; + /** + * @var \TYPO3\CMS\Install\Service\ClearCacheService + */ + protected $installToolClearCacheService; + /** * @param \TYPO3\CMS\Core\DataHandling\DataHandler $dataHandler * @@ -65,6 +70,15 @@ public function injectObjectManager(\TYPO3\CMS\Extbase\Object\ObjectManager $obj $this->objectManager = $objectManager; } + /** + * @param \TYPO3\CMS\Install\Service\ClearCacheService $installToolClearCacheService + * + * @return void + */ + public function injectInstallToolClearCacheService(\TYPO3\CMS\Install\Service\ClearCacheService $installToolClearCacheService) { + $this->installToolClearCacheService = $installToolClearCacheService; + } + /** * Initialize the object. * @@ -84,10 +98,11 @@ public function initializeObject() { /** * Clear all caches. * + * @param bool $hard * @return void */ - public function clearAllCaches() { - $this->dataHandler->clear_cacheCmd('all'); + public function clearAllCaches($hard = FALSE) { + !$hard ? $this->dataHandler->clear_cacheCmd('all') : $this->installToolClearCacheService->clearAll(); } /** @@ -108,6 +123,27 @@ public function clearConfigurationCache() { $this->dataHandler->clear_cacheCmd('temp_cached'); } + /** + * Clear the system cache + * + * @return void + */ + public function clearSystemCache() { + $this->dataHandler->clear_cacheCmd('system'); + } + + /** + * Clears the opcode cache. + * + * @param string|NULL $fileAbsPath The file as absolute path to be cleared + * or NULL to clear completely. + * + * @return void + */ + public function clearAllActiveOpcodeCache($fileAbsPath = NULL) { + $this->clearAllActiveOpcodeCacheWrapper($fileAbsPath); + } + /** * Clear all caches except the page cache. * This is especially useful on big sites when you can't @@ -134,4 +170,16 @@ public function clearAllExceptPageCache() { return $toBeFlushed; } + + /** + * Clears the opcode cache. This just wraps the static call for testing purposes. + * + * @param string|NULL $fileAbsPath The file as absolute path to be cleared + * or NULL to clear completely. + * + * @return void + */ + protected function clearAllActiveOpcodeCacheWrapper($fileAbsPath) { + \TYPO3\CMS\Core\Utility\OpcodeCacheUtility::clearAllActive($fileAbsPath); + } } diff --git a/Classes/Service/DatabaseApiService.php b/Classes/Service/DatabaseApiService.php index 384f705..ca61c98 100644 --- a/Classes/Service/DatabaseApiService.php +++ b/Classes/Service/DatabaseApiService.php @@ -25,7 +25,6 @@ * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ use InvalidArgumentException; -use TYPO3\CMS\Core\Cache\Cache; use TYPO3\CMS\Core\Utility\GeneralUtility; /** @@ -36,24 +35,16 @@ * @package Etobi\CoreAPI\Service\SiteApiService */ class DatabaseApiService { - const ACTION_UPDATE_CLEAR_TABLE = 1; - const ACTION_UPDATE_ADD = 2; - const ACTION_UPDATE_CHANGE = 3; - const ACTION_UPDATE_CREATE_TABLE = 4; - const ACTION_REMOVE_CHANGE = 5; - const ACTION_REMOVE_DROP = 6; - const ACTION_REMOVE_CHANGE_TABLE = 7; - const ACTION_REMOVE_DROP_TABLE = 8; /** - * @var \TYPO3\CMS\Install\Service\SqlSchemaMigrationService $schemaMigrationService Instance of SQL handler + * @var \TYPO3\CMS\Extbase\Object\ObjectManager $objectManager */ - protected $schemaMigrationService; + protected $objectManager; /** - * @var \TYPO3\CMS\Extbase\Object\ObjectManager $objectManager + * @var \Etobi\CoreAPI\Service\DatabaseComparator $comparator */ - protected $objectManager; + protected $comparator = NULL; /** * Inject the ObjectManager @@ -64,116 +55,29 @@ public function injectObjectManager(\TYPO3\CMS\Extbase\Object\ObjectManager $obj $this->objectManager = $objectManager; } - /** - * Inject the SchemaMigrationService - * - * @param \TYPO3\CMS\Install\Service\SqlSchemaMigrationService $schemaMigrationService - */ - public function injectSchemaMigrationService(\TYPO3\CMS\Install\Service\SqlSchemaMigrationService $schemaMigrationService) { - $this->schemaMigrationService = $schemaMigrationService; - } - /** * Database compare. * - * @param string $actions comma separated list of IDs + * @param string $actions comma separated list of IDs + * @param boolean $dry * - * @throws InvalidArgumentException + * @throws \InvalidArgumentException * @return array */ - public function databaseCompare($actions) { - $errors = array(); - - $test = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Reflection\\ClassReflection', 'Etobi\\CoreAPI\\Service\\DatabaseApiService'); - $availableActions = array_flip($test->getConstants()); - - if (empty($actions)) { - throw new InvalidArgumentException('No compare modes defined'); + public function databaseCompare($actions, $dry) { + if ($dry) { + $this->comparator = $this->objectManager->get('Etobi\\CoreAPI\\Service\\DatabaseCompareDry'); + } else { + $this->comparator = $this->objectManager->get('Etobi\\CoreAPI\\Service\\DatabaseCompareReal'); } - $allowedActions = array(); - $actionSplit = $this->trimExplode($actions); - foreach ($actionSplit as $split) { - if (!isset($availableActions[$split])) { - throw new InvalidArgumentException(sprintf('Action "%s" is not available!', $split)); - } - $allowedActions[$split] = 1; - } - - $tblFileContent = ''; - - foreach ($GLOBALS['TYPO3_LOADED_EXT'] as $loadedExtConf) { - if (is_array($loadedExtConf) && $loadedExtConf['ext_tables.sql']) { - $extensionSqlContent = $this->getUrl($loadedExtConf['ext_tables.sql']); - $tblFileContent .= LF . LF . LF . LF . $extensionSqlContent; - } + try { + $result = $this->comparator->databaseCompare($actions); + } catch (\Exception $e) { + throw new \InvalidArgumentException($e->getMessage()); } - if (is_callable('TYPO3\\CMS\\Core\\Cache\\Cache::getDatabaseTableDefinitions')) { - $tblFileContent .= $this->getDatabaseTableDefinitionsFromCache(); - } - - if (class_exists('TYPO3\\CMS\\Core\\Category\\CategoryRegistry')) { - $tblFileContent .= $this->getCategoryRegistry()->getDatabaseTableDefinitions(); - } - - if ($tblFileContent) { - $fileContent = implode(LF, $this->schemaMigrationService->getStatementArray($tblFileContent, 1, '^CREATE TABLE ')); - $fieldDefinitionsFromFile = $this->schemaMigrationService->getFieldDefinitions_fileContent($fileContent); - - $fieldDefinitionsFromDb = $this->schemaMigrationService->getFieldDefinitions_database(); - - $diff = $this->schemaMigrationService->getDatabaseExtra($fieldDefinitionsFromFile, $fieldDefinitionsFromDb); - $updateStatements = $this->schemaMigrationService->getUpdateSuggestions($diff); - - $diff = $this->schemaMigrationService->getDatabaseExtra($fieldDefinitionsFromDb, $fieldDefinitionsFromFile); - $removeStatements = $this->schemaMigrationService->getUpdateSuggestions($diff, 'remove'); - - $allowedRequestKeys = $this->getRequestKeys($updateStatements, $removeStatements); - $results = array(); - - if ($allowedActions[self::ACTION_UPDATE_CLEAR_TABLE] == 1) { - $results[] = $this->schemaMigrationService->performUpdateQueries($updateStatements['clear_table'], $allowedRequestKeys); - } - - if ($allowedActions[self::ACTION_UPDATE_ADD] == 1) { - $results[] = $this->schemaMigrationService->performUpdateQueries($updateStatements['add'], $allowedRequestKeys); - } - - if ($allowedActions[self::ACTION_UPDATE_CHANGE] == 1) { - $results[] = $this->schemaMigrationService->performUpdateQueries($updateStatements['change'], $allowedRequestKeys); - } - - if ($allowedActions[self::ACTION_REMOVE_CHANGE] == 1) { - $results[] = $this->schemaMigrationService->performUpdateQueries($removeStatements['change'], $allowedRequestKeys); - } - - if ($allowedActions[self::ACTION_REMOVE_DROP] == 1) { - $results[] = $this->schemaMigrationService->performUpdateQueries($removeStatements['drop'], $allowedRequestKeys); - } - - if ($allowedActions[self::ACTION_UPDATE_CREATE_TABLE] == 1) { - $results[] = $this->schemaMigrationService->performUpdateQueries($updateStatements['create_table'], $allowedRequestKeys); - } - - if ($allowedActions[self::ACTION_REMOVE_CHANGE_TABLE] == 1) { - $results[] = $this->schemaMigrationService->performUpdateQueries($removeStatements['change_table'], $allowedRequestKeys); - } - - if ($allowedActions[self::ACTION_REMOVE_DROP_TABLE] == 1) { - $results[] = $this->schemaMigrationService->performUpdateQueries($removeStatements['drop_table'], $allowedRequestKeys); - } - - foreach ($results as $resultSet) { - if (is_array($resultSet)) { - foreach ($resultSet as $key => $errorMessage) { - $errors[$key] = $errorMessage; - } - } - } - } - - return $errors; + return $result; } /** @@ -182,7 +86,7 @@ public function databaseCompare($actions) { * @return array */ public function databaseCompareAvailableActions() { - $availableActions = array_flip($this->objectManager->get('TYPO3\\CMS\\Extbase\\Reflection\\ClassReflection', 'Etobi\\CoreAPI\\Service\\DatabaseApiService')->getConstants()); + $availableActions = array_flip($this->objectManager->get('TYPO3\\CMS\\Extbase\\Reflection\\ClassReflection', 'Etobi\\CoreAPI\\Service\\DatabaseComparator')->getConstants()); foreach ($availableActions as $number => $action) { if (!$this->isFirstPartOfString($action, 'ACTION_')) { @@ -192,80 +96,6 @@ public function databaseCompareAvailableActions() { return $availableActions; } - /** - * Get all request keys, even for those requests which are not used. - * - * @param array $update - * @param array $remove - * - * @return array - */ - protected function getRequestKeys(array $update, array $remove) { - $tmpKeys = array(); - - $updateActions = array('clear_table', 'add', 'change', 'create_table'); - $removeActions = array('change', 'drop', 'change_table', 'drop_table'); - - foreach ($updateActions as $updateAction) { - if (isset($update[$updateAction]) && is_array($update[$updateAction])) { - $tmpKeys[] = array_keys($update[$updateAction]); - } - } - - foreach ($removeActions as $removeAction) { - if (isset($remove[$removeAction]) && is_array($remove[$removeAction])) { - $tmpKeys[] = array_keys($remove[$removeAction]); - } - } - - $finalKeys = array(); - foreach ($tmpKeys as $keys) { - foreach ($keys as $key) { - $finalKeys[$key] = TRUE; - } - } - return $finalKeys; - } - - /** - * Wrapper around GeneralUtility::trimExplode - * - * @param string $values The values to explode - * - * @return array - */ - protected function trimExplode($values) { - return GeneralUtility::trimExplode(',', $values); - } - - /** - * Wrapper around GeneralUtility::getUrl() - * @param $url - * - * @return mixed - */ - protected function getUrl($url) { - return GeneralUtility::getUrl($url); - } - - /** - * Wrapper around Cache::getDatabaseTableDefinitions() - * - * @return string - */ - protected function getDatabaseTableDefinitionsFromCache() { - return Cache::getDatabaseTableDefinitions(); - } - - /** - * Wrapper around \TYPO3\CMS\Core\Category\CategoryRegistry::getInstance() - * - * @return \TYPO3\CMS\Core\Category\CategoryRegistry - */ - protected function getCategoryRegistry() { - return \TYPO3\CMS\Core\Category\CategoryRegistry::getInstance(); - } - /** * Wrapper around GeneralUtility::isFirstPartOfStr() * diff --git a/Classes/Service/DatabaseComparator.php b/Classes/Service/DatabaseComparator.php new file mode 100644 index 0000000..e28f4da --- /dev/null +++ b/Classes/Service/DatabaseComparator.php @@ -0,0 +1,140 @@ + + */ +abstract class DatabaseComparator { + const ACTION_UPDATE_CLEAR_TABLE = 1; + const ACTION_UPDATE_ADD = 2; + const ACTION_UPDATE_CHANGE = 3; + const ACTION_UPDATE_CREATE_TABLE = 4; + const ACTION_REMOVE_CHANGE = 5; + const ACTION_REMOVE_DROP = 6; + const ACTION_REMOVE_CHANGE_TABLE = 7; + const ACTION_REMOVE_DROP_TABLE = 8; + + /** + * @var \TYPO3\CMS\Extbase\Object\ObjectManager $objectManager + */ + protected $objectManager; + + /** + * @var \TYPO3\CMS\Install\Service\SqlSchemaMigrationService $schemaMigrationService Instance of SQL handler + */ + protected $schemaMigrationService; + + /** + * @var \TYPO3\CMS\Install\Service\SqlExpectedSchemaService + */ + protected $sqlExpectedSchemaService; + + /** + * Inject the ObjectManager + * + * @param \TYPO3\CMS\Extbase\Object\ObjectManager $objectManager + */ + public function injectObjectManager(\TYPO3\CMS\Extbase\Object\ObjectManager $objectManager) { + $this->objectManager = $objectManager; + } + + /** + * @param \TYPO3\CMS\Install\Service\SqlExpectedSchemaService $sqlExpectedSchemaService + */ + public function injectSqlExpectedSchemaService(SqlExpectedSchemaService $sqlExpectedSchemaService) { + $this->sqlExpectedSchemaService = $sqlExpectedSchemaService; + } + + /** + * Inject the SchemaMigrationService + * + * @param \TYPO3\CMS\Install\Service\SqlSchemaMigrationService $schemaMigrationService + */ + public function injectSchemaMigrationService(\TYPO3\CMS\Install\Service\SqlSchemaMigrationService $schemaMigrationService) { + $this->schemaMigrationService = $schemaMigrationService; + } + + /** + * @param $actions + * + * @return mixed + */ + public final function databaseCompare($actions) { + return $this->compare($actions); + } + + protected abstract function compare($action); + + /** + * Wrapper around GeneralUtility::trimExplode + * + * @param string $values The values to explode + * + * @return array + */ + protected function trimExplode($values) { + return GeneralUtility::trimExplode(',', $values); + } + + /** + * Wrapper around GeneralUtility::getUrl() + * @param $url + * + * @return mixed + */ + protected function getUrl($url) { + return GeneralUtility::getUrl($url); + } + + /** + * Reflect, checks and return the allowed actions + * + * @param string $actions comma separated list of IDs + * @return array + */ + protected function getAllowedActions($actions) { + if (empty($actions)) { + throw new InvalidArgumentException('No compare modes defined'); + } + + $allowedActions = array(); + $availableActions = array_flip( + $this->objectManager->get( + 'TYPO3\\CMS\\Extbase\\Reflection\\ClassReflection', + 'Etobi\\CoreAPI\\Service\\DatabaseComparator' + )->getConstants() + ); + + $actions = $this->trimExplode($actions); + foreach ($actions as $action) { + if (!isset($availableActions[$action])) { + throw new InvalidArgumentException(sprintf('Action "%s" is not available!', $action)); + } + $allowedActions[$action] = 1; + } + + return $allowedActions; + } +} + diff --git a/Classes/Service/DatabaseCompareDry.php b/Classes/Service/DatabaseCompareDry.php new file mode 100644 index 0000000..aa78127 --- /dev/null +++ b/Classes/Service/DatabaseCompareDry.php @@ -0,0 +1,91 @@ + + * @author Stefano Kowalke + */ +class DatabaseCompareDry extends DatabaseComparator { + + /** + * Database compare. + * + * @param string $actions comma separated list of IDs + * @throws InvalidArgumentException + * @return array + */ + public function compare($actions) { + $errors = array(); + $results = array(); + + $allowedActions = $this->getAllowedActions($actions); + + $expectedSchema = $this->sqlExpectedSchemaService->getExpectedDatabaseSchema(); + $currentSchema = $this->schemaMigrationService->getFieldDefinitions_database(); + + $addCreateChange = $this->schemaMigrationService->getDatabaseExtra($expectedSchema, $currentSchema); + $addCreateChange = $this->schemaMigrationService->getUpdateSuggestions($addCreateChange); + + $dropRemove = $this->schemaMigrationService->getDatabaseExtra($currentSchema, $expectedSchema); + $dropRemove = $this->schemaMigrationService->getUpdateSuggestions($dropRemove, 'remove'); + + if ($allowedActions[self::ACTION_UPDATE_CLEAR_TABLE] == 1) { + $results['update_clear_table'] = $addCreateChange['clear_table']; + } + + if ($allowedActions[self::ACTION_UPDATE_ADD] == 1) { + $results['update_add'] = $addCreateChange['add']; + } + + if ($allowedActions[self::ACTION_UPDATE_CHANGE] == 1) { + $results['update_change'] = $addCreateChange['change']; + } + + if ($allowedActions[self::ACTION_UPDATE_CREATE_TABLE] == 1) { + $results['update_create_table'] = $addCreateChange['create_table']; + } + + if ($allowedActions[self::ACTION_REMOVE_CHANGE] == 1) { + $results['remove_change'] = $dropRemove['change']; + } + + if ($allowedActions[self::ACTION_REMOVE_DROP] == 1) { + $results['remove_drop'] = $dropRemove['drop']; + } + + if ($allowedActions[self::ACTION_REMOVE_CHANGE_TABLE] == 1) { + $results['remove_change_table'] = $dropRemove['change_table']; + } + + if ($allowedActions[self::ACTION_REMOVE_DROP_TABLE] == 1) { + $results['remove_drop_table'] = $dropRemove['drop_table']; + } + + foreach ($results as $key => $resultSet) { + if (!empty($resultSet)) { + $errors[$key] = $resultSet; + } + } + + return $errors; + } +} + diff --git a/Classes/Service/DatabaseCompareReal.php b/Classes/Service/DatabaseCompareReal.php new file mode 100644 index 0000000..77d07ab --- /dev/null +++ b/Classes/Service/DatabaseCompareReal.php @@ -0,0 +1,131 @@ + + * @author Stefano Kowalke + */ +class DatabaseCompareReal extends DatabaseComparator { + + /** + * Database compare. + * + * @param string $actions comma separated list of IDs + * + * @throws InvalidArgumentException + * @return array + */ + public function compare($actions) { + $errors = array(); + $results = array(); + + $allowedActions = $this->getAllowedActions($actions); + + $expectedSchema = $this->sqlExpectedSchemaService->getExpectedDatabaseSchema(); + $currentSchema = $this->schemaMigrationService->getFieldDefinitions_database(); + + $addCreateChange = $this->schemaMigrationService->getDatabaseExtra($expectedSchema, $currentSchema); + $addCreateChange = $this->schemaMigrationService->getUpdateSuggestions($addCreateChange); + + $dropRemove = $this->schemaMigrationService->getDatabaseExtra($currentSchema, $expectedSchema); + $dropRemove = $this->schemaMigrationService->getUpdateSuggestions($dropRemove, 'remove'); + + $allowedRequestKeys = $this->getRequestKeys($addCreateChange, $dropRemove); + + if ($allowedActions[self::ACTION_UPDATE_CLEAR_TABLE] == 1) { + $results[] = $this->schemaMigrationService->performUpdateQueries($addCreateChange['clear_table'], $allowedRequestKeys); + } + + if ($allowedActions[self::ACTION_UPDATE_ADD] == 1) { + $results[] = $this->schemaMigrationService->performUpdateQueries($addCreateChange['add'], $allowedRequestKeys); + } + + if ($allowedActions[self::ACTION_UPDATE_CHANGE] == 1) { + $results[] = $this->schemaMigrationService->performUpdateQueries($addCreateChange['change'], $allowedRequestKeys); + } + + if ($allowedActions[self::ACTION_UPDATE_CREATE_TABLE] == 1) { + $results[] = $this->schemaMigrationService->performUpdateQueries($addCreateChange['create_table'], $allowedRequestKeys); + } + + if ($allowedActions[self::ACTION_REMOVE_CHANGE] == 1) { + $results[] = $this->schemaMigrationService->performUpdateQueries($dropRemove['change'], $allowedRequestKeys); + } + + if ($allowedActions[self::ACTION_REMOVE_DROP] == 1) { + $results[] = $this->schemaMigrationService->performUpdateQueries($dropRemove['drop'], $allowedRequestKeys); + } + + if ($allowedActions[self::ACTION_REMOVE_CHANGE_TABLE] == 1) { + $results[] = $this->schemaMigrationService->performUpdateQueries($dropRemove['change_table'], $allowedRequestKeys); + } + + if ($allowedActions[self::ACTION_REMOVE_DROP_TABLE] == 1) { + $results[] = $this->schemaMigrationService->performUpdateQueries($dropRemove['drop_table'], $allowedRequestKeys); + } + + foreach ($results as $resultSet) { + if (is_array($resultSet)) { + foreach ($resultSet as $key => $errorMessage) { + $errors[$key] = $errorMessage; + } + } + } + + return $errors; + } + + /** + * Get all request keys, even for those requests which are not used. + * + * @param array $update + * @param array $remove + * + * @return array + */ + protected function getRequestKeys(array $update, array $remove) { + $tmpKeys = array(); + + $updateActions = array('clear_table', 'add', 'change', 'create_table'); + $removeActions = array('change', 'drop', 'change_table', 'drop_table'); + + foreach ($updateActions as $updateAction) { + if (isset($update[$updateAction]) && is_array($update[$updateAction])) { + $tmpKeys[] = array_keys($update[$updateAction]); + } + } + + foreach ($removeActions as $removeAction) { + if (isset($remove[$removeAction]) && is_array($remove[$removeAction])) { + $tmpKeys[] = array_keys($remove[$removeAction]); + } + } + + $finalKeys = array(); + foreach ($tmpKeys as $keys) { + foreach ($keys as $key) { + $finalKeys[$key] = TRUE; + } + } + return $finalKeys; + } +} + diff --git a/Tests/Unit/Service/CacheApiServiceTest.php b/Tests/Unit/Service/CacheApiServiceTest.php index 9b99aae..9053219 100644 --- a/Tests/Unit/Service/CacheApiServiceTest.php +++ b/Tests/Unit/Service/CacheApiServiceTest.php @@ -124,4 +124,13 @@ public function clearAllExceptPageCacheClearsAllExceptPageCache() { $GLOBALS['typo3CacheManager'] = $cacheManager; $this->subject->clearAllExceptPageCache(); } + + /** + * @test + * @covers ::clearSystemCache + */ + public function clearSystemCacheClearsSystemCache() { + $this->dataHandlerMock->expects($this->once())->method('clear_cacheCmd')->with('system'); + $this->subject->clearSystemCache(); + } } \ No newline at end of file diff --git a/Tests/Unit/Service/DatabaseApiServiceTest.php b/Tests/Unit/Service/DatabaseApiServiceTest.php index 86468ed..36b6e45 100644 --- a/Tests/Unit/Service/DatabaseApiServiceTest.php +++ b/Tests/Unit/Service/DatabaseApiServiceTest.php @@ -27,7 +27,7 @@ * * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ - + use TYPO3\CMS\Core\Tests\UnitTestCase; /** @@ -44,11 +44,17 @@ class DatabaseApiServiceTest extends UnitTestCase { */ protected $subject; + /** + * @var \TYPO3\CMS\Extbase\Object\ObjectManager|\PHPUnit_Framework_MockObject_MockObject $objectManagerMock + */ + protected $objectManagerMock; + /** * Setup the test */ public function setup() { $this->subject = $this->getMock('Etobi\\CoreApi\\Service\\DatabaseApiService', array('dummy')); + $this->objectManagerMock = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManager', array('get')); } /** @@ -61,55 +67,38 @@ public function tearDown() { /** * @test * @covers ::databaseCompare - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage No compare modes defined */ - public function databaseCompareNoCompareModesDefinedThrowsException() { - $objectManagerMock = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManager', array('get')); - $classReflectionMock = $this->getMock('TYPO3\\CMS\\Extbase\\Reflection\\ClassReflection', array(), array(new \Etobi\CoreAPI\Service\DatabaseApiService())); + public function databaseCompareCreatesDatabaseCompareRealObjectWhenNoDryRunIsDemanded() { + $comparator = $this->getMock('Etobi\\CoreAPI\\Service\\DatabaseCompareReal'); + $this->objectManagerMock->expects($this->once())->method('get')->with('Etobi\\CoreAPI\\Service\\DatabaseCompareReal')->will($this->returnValue($comparator)); - $classReflectionMock->expects($this->once())->method('getConstants')->will($this->returnValue($this->getAvailableActions())); - $objectManagerMock->expects($this->once())->method('get')->with('TYPO3\\CMS\\Extbase\\Reflection\\ClassReflection', 'Etobi\\CoreAPI\\Service\\DatabaseApiService')->will($this->returnValue($classReflectionMock)); - $this->subject->injectObjectManager($objectManagerMock); - - $this->subject->databaseCompare(''); + $this->subject->injectObjectManager($this->objectManagerMock); + $this->subject->databaseCompare(1, FALSE); } /** * @test * @covers ::databaseCompare - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Action "10" is not available! */ - public function databaseCompareActionsNoDefinedThrowsException() { - $objectManagerMock = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManager', array('get')); - $classReflectionMock = $this->getMock('TYPO3\\CMS\\Extbase\\Reflection\\ClassReflection', array(), array(new \Etobi\CoreAPI\Service\DatabaseApiService())); - $this->subject = $this->getMock('Etobi\\CoreApi\\Service\\DatabaseApiService', array('trimExplode')); - - $classReflectionMock->expects($this->once())->method('getConstants')->will($this->returnValue($this->getAvailableActions())); - $objectManagerMock->expects($this->once())->method('get')->with('TYPO3\\CMS\\Extbase\\Reflection\\ClassReflection', 'Etobi\\CoreAPI\\Service\\DatabaseApiService')->will($this->returnValue($classReflectionMock)); - $this->subject->expects($this->once())->method('trimExplode')->with('10')->will($this->returnValue(array('10'))); - $this->subject->injectObjectManager($objectManagerMock); + public function databaseCompareCreatesDatabaseCompareDryObjectWhenDryRunIsDemanded() { + $comparator = $this->getMock('Etobi\\CoreAPI\\Service\\DatabaseCompareDry'); + $this->objectManagerMock->expects($this->once())->method('get')->with('Etobi\\CoreAPI\\Service\\DatabaseCompareDry')->will($this->returnValue($comparator)); - $this->subject->databaseCompare('10'); + $this->subject->injectObjectManager($this->objectManagerMock); + $this->subject->databaseCompare(1, TRUE); } + /** * @test * @covers ::databaseCompare */ public function databaseCompareOneAction() { - $this->markTestIncomplete(); - $objectManagerMock = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManager', array('get')); - $classReflectionMock = $this->getMock('TYPO3\\CMS\\Extbase\\Reflection\\ClassReflection', array(), array(new \Etobi\CoreAPI\Service\DatabaseApiService())); - $this->subject = $this->getMock('Etobi\\CoreApi\\Service\\DatabaseApiService', array('trimExplode')); - - $classReflectionMock->expects($this->once())->method('getConstants')->will($this->returnValue($this->getAvailableActions())); - $objectManagerMock->expects($this->once())->method('get')->with('TYPO3\\CMS\\Extbase\\Reflection\\ClassReflection', 'Etobi\\CoreAPI\\Service\\DatabaseApiService')->will($this->returnValue($classReflectionMock)); - $this->subject->expects($this->once())->method('trimExplode')->with('1')->will($this->returnValue(array('1'))); - $this->subject->injectObjectManager($objectManagerMock); + $comparator = $this->getMock('Etobi\\CoreAPI\\Service\\DatabaseCompareReal'); + $this->objectManagerMock->expects($this->once())->method('get')->with('Etobi\\CoreAPI\\Service\\DatabaseCompareReal')->will($this->returnValue($comparator)); + $this->subject->injectObjectManager($this->objectManagerMock); - $this->subject->databaseCompare('1'); + $this->subject->databaseCompare('1', FALSE); } /** diff --git a/composer.json b/composer.json index 12bf043..2db1be6 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "etobi/coreapi", "description": "Provides a simple to use API for common core features. Goal is to be able to do the most common tasks by CLI instead of doing it in the backend/browser.", "type": "typo3-cms-extension", - "version": "1.0.0-beta", + "version": "1.1.0", "keywords": ["typo3", "extension", "deployment", "commandline", "cli"], "authors": [ { diff --git a/ext_autoload.php b/ext_autoload.php index 2cd2bbb..7fc7218 100644 --- a/ext_autoload.php +++ b/ext_autoload.php @@ -4,6 +4,7 @@ $extensionClassesPath = $extensionPath . 'Classes/'; return array( + 'Etobi\CoreAPI\Command\BackendApiCommandController' => $extensionClassesPath . 'Command/BackendApiCommandController.php', 'Etobi\CoreAPI\Command\DatabaseApiCommandController' => $extensionClassesPath . 'Command/DatabaseApiCommandController.php', 'Etobi\CoreAPI\Command\SiteApiCommandController' => $extensionClassesPath . 'Command/SiteApiCommandController.php', 'Etobi\CoreAPI\Command\CacheApiCommandController' => $extensionClassesPath . 'Command/CacheApiCommandController.php', @@ -11,5 +12,8 @@ 'Etobi\CoreAPI\Service\CacheApiService' => $extensionClassesPath . 'Service/CacheApiService.php', 'Etobi\CoreAPI\Service\SiteApiService' => $extensionClassesPath . 'Service/SiteApiService.php', 'Etobi\CoreAPI\Service\DatabaseApiService' => $extensionClassesPath . 'Service/DatabaseApiService.php', + 'Etobi\CoreAPI\Service\DatabaseComparator' => $extensionClassesPath . 'Service/DatabaseComparator.php', + 'Etobi\CoreAPI\Service\DatabaseCompareDry' => $extensionClassesPath . 'Service/DatabaseCompareDry.php', + 'Etobi\CoreAPI\Service\DatabaseCompareReal' => $extensionClassesPath . 'Service/DatabaseCompareReal.php', 'Etobi\CoreAPI\Service\ExtensionApiService' => $extensionClassesPath . 'Service/ExtensionApiService.php' ); diff --git a/ext_emconf.php b/ext_emconf.php index b97d8c8..24320b1 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -10,14 +10,14 @@ 'shy' => '', 'priority' => '', 'module' => '', - 'state' => 'beta', + 'state' => 'stable', 'internal' => '', 'uploadfolder' => '0', 'createDirs' => '', 'modify_tables' => '', 'clearCacheOnLoad' => 0, 'lockType' => '', - 'version' => '1.0.0', + 'version' => '1.1.0', 'constraints' => array( 'depends' => array( 'typo3' => '6.2.0-6.2.99', diff --git a/ext_localconf.php b/ext_localconf.php index e9bdd37..6f9dbe2 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -3,13 +3,9 @@ if (TYPO3_MODE === 'BE') { // Register commands + $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['extbase']['commandControllers'][] = 'Etobi\CoreAPI\Command\BackendApiCommandController'; $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['extbase']['commandControllers'][] = 'Etobi\CoreAPI\Command\DatabaseApiCommandController'; $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['extbase']['commandControllers'][] = 'Etobi\CoreAPI\Command\CacheApiCommandController'; $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['extbase']['commandControllers'][] = 'Etobi\CoreAPI\Command\SiteApiCommandController'; $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['extbase']['commandControllers'][] = 'Etobi\CoreAPI\Command\ExtensionApiCommandController'; -} - -// Register the CLI dispatcher -$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['cliKeys'][$_EXTKEY] = array( - 'EXT:' . $_EXTKEY . '/Scripts/Cli.php', '_CLI_lowlevel' -); \ No newline at end of file +} \ No newline at end of file