38 $this->agent_finder = $agent_finder;
44 $this->setDescription(
"Starts and manages migrations needed after an update of ILIAS");
45 $this->addOption(
"yes",
"y", InputOption::VALUE_NONE,
"Confirm every message of the installation.");
46 $this->addOption(
"run",
"R", InputOption::VALUE_REQUIRED,
"Run the migration with the name given.");
50 InputOption::VALUE_REQUIRED,
51 "Run the selected migration with X steps. Pass " .
Migration::INFINITE .
" for all remaining steps." 56 public function execute(InputInterface $input, OutputInterface $output)
59 $io->printLicenseMessage();
60 $io->title(
"Trigger migrations in ILIAS");
63 if ($input->hasOption(
'run') && !empty($input->getOption(
'run'))) {
74 $migration_name = $input->getOption(
'run');
75 $migrations = $agent->getMigrations();
76 if (!isset($migrations[$migration_name]) || !($migrations[$migration_name] instanceof
Migration)) {
77 $io->
error(
"Aborting Migration, did not find {$migration_name}.");
80 $migration = $migrations[$migration_name];
82 $steps = (int)$input->getOption(
'steps');
86 $io->
text(
"Determined infinite steps to run.");
89 $steps = $migration->getDefaultAmountOfStepsPerRun();
90 $io->
text(
"no --steps option found, fallback to default amount of steps of migration. ($steps)");
93 $io->
text(
"Determined $steps step(s) to run.");
97 $objective =
new Objective\MigrationObjective($migration,
$steps);
105 $objective =
new Objective\ObjectiveWithPreconditions(
111 $io->
inform(
"Preparing Environment for {$steps_text} steps in {$migration_name}");
113 $this->achieveObjective($objective, $env, $io);
122 $migrations = $agent->getMigrations();
123 $count = count($migrations);
125 $io->
inform(
"There are currently no migrations to run.");
133 $io->
inform(
"There are {$count} to run:");
134 foreach ($migrations as $migration_key => $migration) {
136 $migration->prepare($env);
137 $steps = $migration->getRemainingAmountOfSteps();
138 $status =
$steps === 0 ?
"[done]" :
"[remaining steps: {$steps}]";
139 $io->
text($migration_key .
": " . $migration->getLabel() .
" " . $status);
141 $io->
inform(
"Run them by passing --run <migration_id>, e.g. --run $migration_key");
150 $objective =
new Objective\ObjectiveWithPreconditions(
155 $environment = $this->achieveObjective($objective, $environment);
Wrapper around symfonies input and output facilities to provide just the functionality required for t...
An objective is a desired state of the system that is supposed to be created by the setup...
A migration is a potentially long lasting operation that can be broken into discrete steps...
execute(InputInterface $input, OutputInterface $output)
__construct(AgentFinder $agent_finder, array $preconditions)
A non-objective, nothing to do to achieve it...
getRelevantAgent(InputInterface $input)
prepareEnvironmentForMigration(Environment $environment, Migration $migration)
runMigration(InputInterface $input, IOWrapper $io)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
An environment holds resources to be used in the setup process.
configureCommandForPlugins()
__construct(Container $dic, ilPlugin $plugin)
const RESOURCE_ADMIN_INTERACTION
trait HasAgent
Add this to an Command that has an agent.
getRequestedConfirmation()
$preconditions
var Objective[]
listMigrations(InputInterface $input, IOWrapper $io)
Signals that a necessary confirmation from the admin is missing.
getPreconditions(Environment $environment)
Objectives the migration depend on.