aboutsummaryrefslogtreecommitdiff
path: root/cli/Commands/DI/Reset.php
diff options
context:
space:
mode:
authorPhilipp Schüttlöffel <schuettloeffel@zqs.uni-hannover.de>2024-09-24 10:53:31 +0200
committerPhilipp Schüttlöffel <schuettloeffel@zqs.uni-hannover.de>2024-09-24 10:53:31 +0200
commit4459dd7917f4d1c34f40bb68f0e991e9c3d53e4c (patch)
tree5c07151ae61276d334e88f6309c30d439a85c12e /cli/Commands/DI/Reset.php
parentda0022e5c1abbf9825ae76debaabdff7e8623bb4 (diff)
parent97a188592c679890a25c37ab78463add76a52ff7 (diff)
Merge branch 'main' into issue-3911issue-3911
Diffstat (limited to 'cli/Commands/DI/Reset.php')
-rw-r--r--cli/Commands/DI/Reset.php30
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;
+ }
+}