ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ILIAS\Setup\CLI\MigrateCommand Class Reference

Migration command. More...

+ Inheritance diagram for ILIAS\Setup\CLI\MigrateCommand:
+ Collaboration diagram for ILIAS\Setup\CLI\MigrateCommand:

Public Member Functions

 __construct (AgentFinder $agent_finder, array $preconditions)
 

Protected Member Functions

 configure ()
 
 execute (InputInterface $input, OutputInterface $output)
 
 runMigration (InputInterface $input, IOWrapper $io)
 
 listMigrations (InputInterface $input, IOWrapper $io)
 
 prepareEnvironmentForMigration (Environment $environment, Migration $migration)
 

Protected Attributes

array $preconditions
 var Objective[] More...
 

Static Protected Attributes

static $defaultName = "migrate"
 

Detailed Description

Migration command.

Definition at line 37 of file MigrateCommand.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Setup\CLI\MigrateCommand::__construct ( AgentFinder  $agent_finder,
array  $preconditions 
)

Definition at line 52 of file MigrateCommand.php.

References ILIAS\Setup\CLI\MigrateCommand\$preconditions, and ILIAS\GlobalScreen\Provider\__construct().

53  {
55  $this->agent_finder = $agent_finder;
56  $this->preconditions = $preconditions;
57  }
__construct(Container $dic, ilPlugin $plugin)
array $preconditions
var Objective[]
+ Here is the call graph for this function:

Member Function Documentation

◆ configure()

ILIAS\Setup\CLI\MigrateCommand::configure ( )
protected

Definition at line 59 of file MigrateCommand.php.

References ILIAS\Setup\CLI\configureCommandForPlugins(), and ILIAS\Setup\Migration\INFINITE.

59  : void
60  {
61  $this->setDescription("Starts and manages migrations needed after an update of ILIAS");
62  $this->addOption("yes", "y", InputOption::VALUE_NONE, "Confirm every message of the installation.");
63  $this->addOption("run", "R", InputOption::VALUE_REQUIRED, "Run the migration with the name given.");
64  $this->addOption(
65  "steps",
66  "S",
67  InputOption::VALUE_REQUIRED,
68  "Run the selected migration with X steps. Pass " . Migration::INFINITE . " for all remaining steps."
69  );
71  }
configureCommandForPlugins()
Definition: HasAgent.php:33
+ Here is the call graph for this function:

◆ execute()

ILIAS\Setup\CLI\MigrateCommand::execute ( InputInterface  $input,
OutputInterface  $output 
)
protected

Definition at line 73 of file MigrateCommand.php.

References ILIAS\Setup\CLI\MigrateCommand\listMigrations(), and ILIAS\Setup\CLI\MigrateCommand\runMigration().

73  : int
74  {
75  $io = new IOWrapper($input, $output);
76  $io->printLicenseMessage();
77  $io->title("Trigger migrations in ILIAS");
78 
79  // Dispatching further sub-commands
80  if ($input->hasOption('run') && !empty($input->getOption('run'))) {
81  $this->runMigration($input, $io);
82  } else {
83  $this->listMigrations($input, $io);
84  }
85 
86  return 0;
87  }
runMigration(InputInterface $input, IOWrapper $io)
listMigrations(InputInterface $input, IOWrapper $io)
+ Here is the call graph for this function:

◆ listMigrations()

ILIAS\Setup\CLI\MigrateCommand::listMigrations ( InputInterface  $input,
IOWrapper  $io 
)
protected

Definition at line 138 of file MigrateCommand.php.

References $steps, ILIAS\Setup\CLI\getRelevantAgent(), ILIAS\Setup\CLI\IOWrapper\inform(), ILIAS\Setup\CLI\MigrateCommand\prepareEnvironmentForMigration(), ILIAS\Setup\Environment\RESOURCE_ADMIN_INTERACTION, and ILIAS\Setup\CLI\IOWrapper\text().

Referenced by ILIAS\Setup\CLI\MigrateCommand\execute().

138  : void
139  {
140  $agent = $this->getRelevantAgent($input);
141  $migrations = $agent->getMigrations();
142  $count = count($migrations);
143  if ($count === 0) {
144  $io->inform("There are currently no migrations to run.");
145  return;
146  }
147 
148  $env = new ArrayEnvironment([
150  ]);
151 
152  $io->inform("Found $count migrations:");
153  foreach ($migrations as $migration_key => $migration) {
154  $env = $this->prepareEnvironmentForMigration($env, $migration);
155  $migration->prepare($env);
156  $steps = $migration->getRemainingAmountOfSteps();
157  $status = $steps === 0 ? "[done]" : "[remaining steps: $steps]";
158  $io->text($migration_key . ": " . $migration->getLabel() . " " . $status);
159  }
160  $io->inform('Run them by passing --run <migration_id>, e.g. --run ' . $migration_key);
161  }
getRelevantAgent(InputInterface $input)
Definition: HasAgent.php:40
prepareEnvironmentForMigration(Environment $environment, Migration $migration)
$steps
Definition: latex.php:3
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ prepareEnvironmentForMigration()

ILIAS\Setup\CLI\MigrateCommand::prepareEnvironmentForMigration ( Environment  $environment,
Migration  $migration 
)
protected

Definition at line 163 of file MigrateCommand.php.

References ILIAS\Setup\Migration\getPreconditions().

Referenced by ILIAS\Setup\CLI\MigrateCommand\listMigrations().

166  : Environment {
167  $preconditions = $migration->getPreconditions($environment);
168  if ($preconditions !== []) {
169  $objective = new Objective\ObjectiveWithPreconditions(
170  new Objective\NullObjective(),
171  ...$preconditions
172  );
173 
174  $environment = $this->achieveObjective($objective, $environment);
175  }
176 
177  return $environment;
178  }
array $preconditions
var Objective[]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ runMigration()

ILIAS\Setup\CLI\MigrateCommand::runMigration ( InputInterface  $input,
IOWrapper  $io 
)
protected

Definition at line 89 of file MigrateCommand.php.

References Vendor\Package\$e, $steps, ILIAS\Setup\CLI\IOWrapper\error(), ILIAS\Setup\CLI\getRelevantAgent(), ILIAS\Setup\NoConfirmationException\getRequestedConfirmation(), ILIAS\Setup\Migration\INFINITE, ILIAS\Setup\CLI\IOWrapper\inform(), ILIAS\Repository\int(), ILIAS\Setup\Environment\RESOURCE_ADMIN_INTERACTION, and ILIAS\Setup\CLI\IOWrapper\text().

Referenced by ILIAS\Setup\CLI\MigrateCommand\execute().

89  : void
90  {
91  $agent = $this->getRelevantAgent($input);
92 
93  $migration_name = $input->getOption('run');
94  $migrations = $agent->getMigrations();
95  if (!isset($migrations[$migration_name]) || !($migrations[$migration_name] instanceof Migration)) {
96  $io->error("Aborting Migration, did not find $migration_name.");
97  return;
98  }
99  $migration = $migrations[$migration_name];
100 
101  $steps = (int) $input->getOption('steps');
102 
103  switch ($steps) {
104  case Migration::INFINITE:
105  $io->text("Determined infinite steps to run.");
106  break;
107  case 0:
108  $steps = $migration->getDefaultAmountOfStepsPerRun();
109  $io->text("no --steps option found, fallback to default amount of steps of migration. ($steps)");
110  break;
111  default:
112  $io->text("Determined $steps step(s) to run.");
113  break;
114 
115  }
116  $objective = new Objective\MigrationObjective($migration, $steps);
117 
118  $env = new ArrayEnvironment([
120  ]);
121 
122  $preconditions = $migration->getPreconditions($env);
123  if ($preconditions !== []) {
124  $objective = new Objective\ObjectiveWithPreconditions(
125  $objective,
126  ...$preconditions
127  );
128  }
129  $steps_text = $steps === Migration::INFINITE ? 'all' : (string) $steps;
130  $io->inform("Preparing Environment for {$steps_text} steps in {$migration_name}");
131  try {
132  $this->achieveObjective($objective, $env, $io);
133  } catch (NoConfirmationException $e) {
134  $io->error("Aborting Migration, a necessary confirmation is missing:\n\n" . $e->getRequestedConfirmation());
135  }
136  }
getRelevantAgent(InputInterface $input)
Definition: HasAgent.php:40
$steps
Definition: latex.php:3
array $preconditions
var Objective[]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $defaultName

ILIAS\Setup\CLI\MigrateCommand::$defaultName = "migrate"
staticprotected

Definition at line 42 of file MigrateCommand.php.

◆ $preconditions

array ILIAS\Setup\CLI\MigrateCommand::$preconditions
protected

var Objective[]

Definition at line 47 of file MigrateCommand.php.

Referenced by ILIAS\Setup\CLI\MigrateCommand\__construct().


The documentation for this class was generated from the following file: