ClearGeneratedAvatarCacheCommand.php 911 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OC\Core\Command\User;
  8. use OC\Avatar\AvatarManager;
  9. use OC\Core\Command\Base;
  10. use Symfony\Component\Console\Input\InputInterface;
  11. use Symfony\Component\Console\Output\OutputInterface;
  12. class ClearGeneratedAvatarCacheCommand extends Base {
  13. public function __construct(
  14. protected AvatarManager $avatarManager,
  15. ) {
  16. parent::__construct();
  17. }
  18. protected function configure(): void {
  19. $this
  20. ->setDescription('clear avatar cache')
  21. ->setName('user:clear-avatar-cache');
  22. }
  23. protected function execute(InputInterface $input, OutputInterface $output): int {
  24. $output->writeln("Clearing avatar cache has started");
  25. $this->avatarManager->clearCachedAvatars();
  26. $output->writeln("Cleared avatar cache successfully");
  27. return 0;
  28. }
  29. }