Skip to content
Snippets Groups Projects
Commit 922feaed authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms
Browse files

add command to reset compiled di container, fixes #3979

Closes #3979

Merge request studip/studip!2829
parent bcd76d3c
No related branches found
No related tags found
No related merge requests found
<?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;
}
}
......@@ -33,6 +33,7 @@ $commands = [
Commands\Cronjobs\CronjobWorker::class,
Commands\DB\Dump::class,
Commands\DB\MoveMatrikelnummer::class,
Commands\DI\Reset::class,
Commands\Files\Dump::class,
Commands\Fix\Biest7789::class,
Commands\Fix\Biest7866::class,
......
......@@ -47,7 +47,10 @@ class DIContainer
{
$builder = new ContainerBuilder();
if (\Studip\ENV == 'production') {
$builder->enableCompilation($GLOBALS['TMP_PATH']);
$builder->enableCompilation(
self::getCompilationPath(),
self::getCompilationClass()
);
}
$builder->ignorePhpDocErrors(true);
$builder->addDefinitions('lib/bootstrap-definitions.php');
......@@ -60,4 +63,14 @@ class DIContainer
return $builder;
}
public static function getCompilationPath(): string
{
return $GLOBALS['TMP_PATH'];
}
public static function getCompilationClass(): string
{
return 'CompiledContainer';
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment