-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
21a349d
commit 844d90b
Showing
1 changed file
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
/** | ||
* FOSSBilling. | ||
* | ||
* @copyright FOSSBilling (https://www.fossbilling.org) | ||
* @license Apache-2.0 | ||
* | ||
* Copyright FOSSBilling 2022 | ||
* This software may contain code previously used in the BoxBilling project. | ||
* Copyright BoxBilling, Inc 2011-2021 | ||
* | ||
* This source file is subject to the Apache-2.0 License that is bundled | ||
* with this source code in the file LICENSE | ||
*/ | ||
|
||
namespace Box\Mod\Example\Console; | ||
|
||
use Pimple\Container; | ||
use CristianG\PimpleConsole\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
|
||
class ExampleDI extends Command implements \FOSSBilling\InjectionAwareInterface | ||
{ | ||
protected ?Container $di = null; | ||
|
||
/** | ||
* @param Container $di | ||
* @return void | ||
*/ | ||
public function setDi(Container $di): void | ||
{ | ||
$this->di = $di; | ||
} | ||
|
||
/** | ||
* @return Container|null | ||
*/ | ||
public function getDi(): ?Container | ||
{ | ||
return $this->di; | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
protected function configure(): void | ||
{ | ||
$this->setName('example:clear'); | ||
$this->setDescription('Clear your cache in example'); | ||
parent::configure(); | ||
} | ||
|
||
/** | ||
* @param InputInterface $input | ||
* @param OutputInterface $output | ||
* @return int | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
Check failure on line 61 in src/Console/ExampleDI.php GitHub Actions / PHPStan - FOSSBilling Release
|
||
{ | ||
$service = $this->di['mod_service']('system'); | ||
try { | ||
$service->clearCache(); | ||
} catch (\Exception $e) { | ||
$this->error("An error occurred: ".$e->getMessage()); | ||
return Command::FAILURE; | ||
} finally { | ||
$this->info("Successfully cleared the cache."); | ||
return Command::SUCCESS; | ||
} | ||
} | ||
} |