8000 Clear system cache by bgmgmbh · Pull Request #71 · TYPO3-coreapi/ext-coreapi · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Aug 15, 2023. It is now read-only.

Clear system cache #71

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .scrutinizer.yml
10000
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
filter:
excluded_paths:
- 'Resources/Public/vendor/*'

tools:

external_code_coverage:
timeout: 700

php_sim: true

php_code_sniffer:
enabled: true
config:
standard: TYPO3CMS

php_cs_fixer:
enabled: false

php_mess_detector:
enabled: true
config:
code_size_rules:
cyclomatic_complexity: true
npath_complexity: true
excessive_class_complexity: true
controversial_rules:
superglobals: false

php_pdepend:
enabled: true

php_analyzer:
enabled: true
config:
basic_semantic_checks:
enabled: true
property_on_interface: true
missing_abstract_methods: true
deprecation_checks:
enabled: true
simplify_boolean_return:
enabled: true
metrics_lack_of_cohesion_methods:
enabled: true
dead_assignments:
enabled: true

sensiolabs_security_checker: true
49 changes: 49 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
language: php
php:
- 5.3
- 5.4
- 5.5
- 5.6

env:
- DB=mysql TYPO3=master INTEGRATION=master COVERAGE=0

services:
- memcached
- redis-server

notifications:
email:
- blueduck@gmx.net

before_script:
# Get latest git version cause of travis issues (https://github.com/travis-ci/travis-ci/issues/1710)
- sudo apt-get update && sudo apt-get install git parallel tree
- >
if [[ "$TRAVIS_PHP_VERSION" = "5.3" || "$TRAVIS_PHP_VERSION" = "5.4" ]]; then
echo "extension = apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini;
echo "apc.enable_cli=1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini;
echo "apc.slam_defense=0" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini;
pecl install igbinary > /dev/null;
fi
- echo "extension = memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- echo "extension = redis.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- cd ..
- git clone --single-branch --branch $INTEGRATION --depth 1 git://github.com/TYPO3-coreapi/TYPO3-Travis-Integration.git build-environment
- source build-environment/install-helper.sh
- git clone --single-branch --branch $TYPO3 --depth 1 https://github.com/TYPO3-coreapi/TYPO3CMS.git core
- mv core/* .
- composer self-update
- composer --dev install
- mkdir -p fileadmin uploads typo3temp typo3conf/ext/
- mv ext-coreapi typo3conf/ext/coreapi

script:
- phpLint typo3conf/ext/coreapi
- >
echo;
echo "Running unit tests";
./bin/phpunit --colors --coverage-clover=coverage.clover -c typo3/sysext/core/Build/UnitTests.xml typo3conf/ext/coreapi/Tests/Unit/
- wget https://scrutinizer-ci.com/ocular.phar
- cp -R typo3conf/ext/coreapi/.git .
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover
40 changes: 29 additions & 11 deletions Classes/Command/CacheApiCommandController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,27 @@
*/
class CacheApiCommandController extends CommandController {

/**
* @var \Etobi\CoreAPI\Service\CacheApiService
*/
protected $cacheApiService;

/**
* Inject the CacheApiService
*
* @param \Etobi\CoreAPI\Service\CacheApiService $cacheApiService
*/
public function injectCacheApiService(\Etobi\CoreAPI\Service\CacheApiService $cacheApiService) {
$this->cacheApiService = $cacheApiService;
}

/**
* Clear all caches.
*
* @return void
*/
public function clearAllCachesCommand() {
$service = $this->getService();
$service->clearAllCaches();

$this->cacheApiService->clearAllCaches();
$this->outputLine('All caches have been cleared.');
}

Expand All @@ -53,9 +65,7 @@ public function clearAllCachesCommand() {
* @return void
*/
public function clearConfigurationCacheCommand() {
$service = $this->getService();
$service->clearConfigurationCache();

$this->cacheApiService->clearConfigurationCache();
$this->outputLine('Configuration cache has been cleared.');
}

Expand All @@ -65,9 +75,7 @@ public function clearConfigurationCacheCommand() {
* @return void
*/
public function clearPageCacheCommand() {
$service = $this->getService();
$service->clearPageCache();

$this->cacheApiService->clearPageCache();
$this->outputLine('Page cache has been cleared.');
}

Expand All @@ -78,10 +86,20 @@ public function clearPageCacheCommand() {
* @return void
*/
public function clearAllExceptPageCacheCommand() {
$clearedCaches = $this->cacheApiService->clearAllExceptPageCache();
$this->outputLine('Cleared caches: ' . implode(', ', $clearedCaches));
}

/**
* Clear system cache.
*
* @return void
*/
public function clearSystemCacheCommand() {
$service = $this->getService();
$clearedCaches = $service->clearAllExceptPageCache();
$service->clearSystemCache();

$this->outputLine('Cleared caches: ' . implode(', ', $clearedCaches));
$this->outputLine('System cache has been cleared.');
}

/**
Expand Down
81 changes: 48 additions & 33 deletions Classes/Command/ExtensionApiCommandController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@
*/
class ExtensionApiCommandController extends CommandController {

/**
* @var \Etobi\CoreAPI\Service\ExtensionApiService
* @inject
*/
protected $extensionApiService;

/**
* Information about an extension.
*
Expand All @@ -48,8 +54,7 @@ class ExtensionApiCommandController extends CommandController {
public function infoCommand($key) {
$data = array();
try {
$service = $this->getService();
$data = $service->getExtensionInformation($key);
$data = $this->extensionApiService->getExtensionInformation($key);
} catch (Exception $e) {
$this->outputLine($e->getMessage());
$this->quit();
Expand Down Expand Up @@ -101,7 +106,9 @@ public function infoCommand($key) {
/**
* List all installed extensions.
*
* @param string $type Extension type, can either be L for local, S for system or G for global. Leave it empty for all
* @param string $type Extension type, can either be
* L for local, S for system or G for global.
* Leave it empty for all
*
* @return void
*/
Expand All @@ -112,7 +119,7 @@ public function listInstalledCommand($type = '') {
$this->quit();
}

$extensions = $this->getService()->getInstalledExtensions($type);
$extensions = $this->extensionApiService->getInstalledExtensions($type);

foreach ($extensions as $key => $details) {
$title = $key . ' - ' . $details['version'] . '/' . $details['state'];
Expand All @@ -131,10 +138,14 @@ public function listInstalledCommand($type = '') {
* @return void
*/
public function updateListCommand() {
$service = $this->getService();
$service->updateMirrors();
$this->outputLine('This may take a while...');
$result = $this->extensionApiService->updateMirrors();

$this->outputLine('Extension list has been updated.');
if ($result) {
$this->outputLine('Extension list has been updated.');
} else {
$this->outputLine('Extension list already up-to-date.');
}
}

/**
Expand All @@ -146,8 +157,7 @@ public function updateListCommand() {
*/
public function installCommand($key) {
try {
$service = $this->getService();
$service->installExtension($key);
$this->extensionApiService->installExtension($key);
} catch (Exception $e) {
$this->outputLine($e->getMessage());
$this->quit();
Expand All @@ -164,8 +174,7 @@ public function installCommand($key) {
*/
public function uninstallCommand($key) {
try {
$service = $this->getService();
$service->uninstallExtension($key);
$this->extensionApiService->uninstallExtension($key);
} catch (Exception $e) {
$this->outputLine($e->getMessage());
$this->quit();
Expand Down Expand Up @@ -196,7 +205,6 @@ public function uninstallCommand($key) {
*/
public function configureCommand($key, $configfile = '', $settings = '') {
try {
$service = $this->getService();
$conf = array();
if (is_file($configfile)) {
$conf = parse_ini_file($configfile);
Expand All @@ -219,7 +227,7 @@ public function configureCommand($key, $configfile = '', $settings = '') {
throw new InvalidArgumentException(sprintf('No configuration settings!', $key));
}

$service->configureExtension($key, $conf);
$this->extensionApiService->configureExtension($key, $conf);

} catch (Exception $e) {
$this->outputLine($e->getMessage());
Expand All @@ -233,36 +241,53 @@ public function configureCommand($key, $configfile = '', $settings = '') {
*
* @param string $key extension key
* @param string $version the exact version of the extension, otherwise the latest will be picked
* @param string $location where to put the extension. S = typo3/sysext, G = typo3/ext, L = typo3conf/ext
* @param string $location where to put the extension. System = typo3/sysext, Global = typo3/ext, Local = typo3conf/ext
* @param bool $overwrite overwrite the extension if it already exists
* @param string $mirror mirror to fetch the extension from, otherwise a random mirror will be selected
* @param int $mirror mirror to fetch the extension from. Run extensionapi:listmirrors to get the list of all available repositories, otherwise a random mirror will be selected
*
* @return void
*/
public function fetchCommand($key, $version = '', $location = 'L', $overwrite = FALSE, $mirror = '') {
public function fetchCommand($key, $version = '', $location = 'Local', $overwrite = FALSE, $mirror = -1) {
try {
$service = $this->getService();
$data = $service->fetchExtension($key, $version, $location, $overwrite, $mirror);
$data = $this->extensionApiService->fetchExtension($key, $version, $location, $overwrite, $mirror);
$this->outputLine(sprintf('Extension "%s" version %s has been fetched from repository!', $data['extKey'], $data['version']));
} catch (Exception $e) {
$this->outputLine($e->getMessage());
$this->quit();
}
}

/**
* Lists the possible mirrors
*
* @return void
*/
public function listMirrorsCommand() {
try {
$mirros = $this->extensionApiService->listMirrors();
$key = 0;
foreach ($mirros as $mirror) {
$this->outputLine($key . ' = ' . $mirror['title'] . ' ' . $mirror['host']);
++$key;
}
} catch (Exception $e) {
$this->outputLine($e->getMessage());
$this->quit();
}
}

/**
* Import extension from file.
*
* @param string $file path to t3x file
* @param string $location where to import the extension. S = typo3/sysext, G = typo3/ext, L = typo3conf/ext
* @param string $location where to import the extension. System = typo3/sysext, Global = typo3/ext, Local = typo3conf/ext
* @param boolean $overwrite overwrite the extension if it already exists
*
* @return void
*/
public function importCommand($file, $location = 'L', $overwrite = FALSE) {
public function importCommand($file, $location = 'Local', $overwrite = FALSE) {
try {
$service = $this->getService();
$data = $service->importExtension($file, $location, $overwrite);
$data = $this->extensionApiService->importExtension($file, $location, $overwrite);
$this->outputLine(sprintf('Extension "%s" has been imported!', $data['extKey']));
} catch (Exception $e) {
$this->outputLine($e->getMessage());
Expand All @@ -276,8 +301,7 @@ public function importCommand($file, $location = 'L', $overwrite = FALSE) {
* @return void
*/
public function createUploadFoldersCommand() {
$service = $this->getService();
$messages = $service->createUploadFolders();
$messages = $this->extensionApiService->createUploadFolders();

if (sizeof($messages)) {
foreach ($messages as $message) {
Expand All @@ -287,13 +311,4 @@ public function createUploadFoldersCommand() {
$this->outputLine('no uploadFolder created');
}
}

/**
* Returns the service object.
*
* @return \Etobi\CoreAPI\Service\ExtensionApiService object
*/
private function getService() {
return $this->objectManager->get('Etobi\\CoreAPI\\Service\\ExtensionApiService');
}
}
Loading
0