ClearGeneratedAvatarCacheCommand.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2024, Nextcloud GmbH
  5. *
  6. * @author Kareem <yemkareems@gmail.com>
  7. * @license AGPL-3.0-or-later
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License as
  11. * published by the Free Software Foundation, either version 3 of the
  12. * License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. *
  22. */
  23. namespace OC\Core\Command\User;
  24. use OC\Avatar\AvatarManager;
  25. use OC\Core\Command\Base;
  26. use Symfony\Component\Console\Input\InputInterface;
  27. use Symfony\Component\Console\Output\OutputInterface;
  28. class ClearGeneratedAvatarCacheCommand extends Base {
  29. public function __construct(
  30. protected AvatarManager $avatarManager,
  31. ) {
  32. parent::__construct();
  33. }
  34. protected function configure(): void {
  35. $this
  36. ->setDescription('clear avatar cache')
  37. ->setName('user:clear-avatar-cache');
  38. }
  39. protected function execute(InputInterface $input, OutputInterface $output): int {
  40. $output->writeln("Clearing avatar cache has started");
  41. $this->avatarManager->clearCachedAvatars();
  42. $output->writeln("Cleared avatar cache successfully");
  43. return 0;
  44. }
  45. }