diff options
| author | Philipp Schüttlöffel <schuettloeffel@zqs.uni-hannover.de> | 2024-09-24 10:53:31 +0200 |
|---|---|---|
| committer | Philipp Schüttlöffel <schuettloeffel@zqs.uni-hannover.de> | 2024-09-24 10:53:31 +0200 |
| commit | 4459dd7917f4d1c34f40bb68f0e991e9c3d53e4c (patch) | |
| tree | 5c07151ae61276d334e88f6309c30d439a85c12e /cli/Commands/DI/Reset.php | |
| parent | da0022e5c1abbf9825ae76debaabdff7e8623bb4 (diff) | |
| parent | 97a188592c679890a25c37ab78463add76a52ff7 (diff) | |
Merge branch 'main' into issue-3911issue-3911
Diffstat (limited to 'cli/Commands/DI/Reset.php')
| -rw-r--r-- | cli/Commands/DI/Reset.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/cli/Commands/DI/Reset.php b/cli/Commands/DI/Reset.php new file mode 100644 index 0000000..646bfb6 --- /dev/null +++ b/cli/Commands/DI/Reset.php @@ -0,0 +1,30 @@ +<?php + +namespace Studip\Cli\Commands\DI; + +use Studip\DIContainer; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +class Reset extends Command +{ + protected static $defaultName = 'di:reset'; + + protected function configure(): void + { + $this->setDescription('Resets the compiled DI container'); + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + $file = DIContainer::getCompilationPath() . '/' . DIContainer::getCompilationClass() . '.php'; + + if (file_exists($file) && !unlink($file)) { + $output->writeln('<error>Could not removed compiled file.</error>'); + return Command::FAILURE; + } + + return Command::SUCCESS; + } +} |
