mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-12-02 21:30:16 +09:00
* Improve type safety, auth checks and PHPStan fixes * Remove @phpstan-ignore annotations * Improve type safety, auth checks and PHPStan fixes * Remove @phpstan-ignore annotations * Remove redundant @phpstan-ignore comment
55 lines
1.3 KiB
PHP
55 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
/**
|
|
* Copyright 2022-2025 FOSSBilling
|
|
* Copyright 2011-2021 BoxBilling, Inc.
|
|
* SPDX-License-Identifier: Apache-2.0.
|
|
*
|
|
* @copyright FOSSBilling (https://www.fossbilling.org)
|
|
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache-2.0
|
|
*/
|
|
|
|
namespace Box\Mod\System\Commands;
|
|
|
|
use Symfony\Component\Console\Attribute\AsCommand;
|
|
use Symfony\Component\Console\Command\Command;
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
#[AsCommand(
|
|
name: 'cache:clear',
|
|
description: 'Clears the cache',
|
|
hidden: false
|
|
)]
|
|
class CacheClear extends Command implements \FOSSBilling\InjectionAwareInterface
|
|
{
|
|
protected $di;
|
|
|
|
public function setDi($di): void
|
|
{
|
|
$this->di = $di;
|
|
}
|
|
|
|
public function getDi(): ?\Pimple\Container
|
|
{
|
|
return $this->di;
|
|
}
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
|
{
|
|
$service = $this->di['mod_service']('system');
|
|
|
|
try {
|
|
$service->clearCache();
|
|
} catch (\Exception $e) {
|
|
$output->writeln("<error>An error occurred: {$e->getMessage()}</error>");
|
|
|
|
return Command::FAILURE;
|
|
}
|
|
$output->writeln('<info>Successfully cleared the cache.</info>');
|
|
|
|
return Command::SUCCESS;
|
|
}
|
|
}
|