appDataFactory->get('dav-photocache'); $folders = $photoCacheAppData->getDirectoryListing(); $countFolders = count($folders); if ($countFolders === 0) { $output->writeln('No cached contact photos found.'); return self::SUCCESS; } $output->writeln('Found ' . count($folders) . ' cached contact photos.'); /** @var QuestionHelper $helper */ $helper = $this->getHelper('question'); $question = new ConfirmationQuestion('Please confirm to clear the contacts photo cache [y/n] ', true); if ($helper->ask($input, $output, $question) === false) { $output->writeln('Clearing the contacts photo cache aborted.'); return self::SUCCESS; } $progressBar = new ProgressBar($output, $countFolders); $progressBar->start(); foreach ($folders as $folder) { try { $folder->delete(); } catch (NotPermittedException) { } $progressBar->advance(); } $progressBar->finish(); $output->writeln(''); $output->writeln('Contacts photo cache cleared.'); return self::SUCCESS; } }