ILIAS  release_7 Revision v7.30-3-g800a261c036
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)
 
 configure ()
 
 execute (InputInterface $input, OutputInterface $output)
 

Protected Member Functions

 runMigration (InputInterface $input, IOWrapper $io)
 
 listMigrations (InputInterface $input, IOWrapper $io)
 
 prepareEnvironmentForMigration (Environment $environment, Migration $migration)
 

Protected Attributes

 $preconditions
 var Objective[] More...
 

Static Protected Attributes

static $defaultName = "migrate"
 

Detailed Description

Migration command.

Definition at line 20 of file MigrateCommand.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 35 of file MigrateCommand.php.

36 {
38 $this->agent_finder = $agent_finder;
39 $this->preconditions = $preconditions;
40 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

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

+ Here is the call graph for this function:

Member Function Documentation

◆ configure()

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

Definition at line 42 of file MigrateCommand.php.

43 {
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.");
47 $this->addOption(
48 "steps",
49 "S",
50 InputOption::VALUE_REQUIRED,
51 "Run the selected migration with X steps. Pass " . Migration::INFINITE . " for all remaining steps."
52 );
54 }
configureCommandForPlugins()
Definition: HasAgent.php:21

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

+ Here is the call graph for this function:

◆ execute()

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

Definition at line 56 of file MigrateCommand.php.

57 {
58 $io = new IOWrapper($input, $output);
59 $io->printLicenseMessage();
60 $io->title("Trigger migrations in ILIAS");
61
62 // Dispatching further sub-commands
63 if ($input->hasOption('run') && !empty($input->getOption('run'))) {
64 $this->runMigration($input, $io);
65 } else {
66 $this->listMigrations($input, $io);
67 }
68 }
runMigration(InputInterface $input, IOWrapper $io)
listMigrations(InputInterface $input, IOWrapper $io)

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

+ Here is the call graph for this function:

◆ listMigrations()

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

Definition at line 119 of file MigrateCommand.php.

119 : void
120 {
121 $agent = $this->getRelevantAgent($input);
122 $migrations = $agent->getMigrations();
123 $count = count($migrations);
124 if ($count === 0) {
125 $io->inform("There are currently no migrations to run.");
126 return;
127 }
128
129 $env = new ArrayEnvironment([
131 ]);
132
133 $io->inform("There are {$count} to run:");
134 foreach ($migrations as $migration_key => $migration) {
135 $env = $this->prepareEnvironmentForMigration($env, $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);
140 }
141 $io->inform("Run them by passing --run <migration_id>, e.g. --run $migration_key");
142 }
prepareEnvironmentForMigration(Environment $environment, Migration $migration)
$steps
Definition: latex.php:3
getRelevantAgent(InputInterface $input)
Definition: HasAgent.php:28

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().

+ 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 144 of file MigrateCommand.php.

147 : Environment {
148 $preconditions = $migration->getPreconditions($environment);
149 if (count($preconditions) > 0) {
150 $objective = new Objective\ObjectiveWithPreconditions(
151 new Objective\NullObjective(),
153 );
154
155 $environment = $this->achieveObjective($objective, $environment);
156 }
157
158 return $environment;
159 }

References ILIAS\Setup\CLI\MigrateCommand\$preconditions.

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

+ Here is the caller graph for this function:

◆ runMigration()

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

Definition at line 70 of file MigrateCommand.php.

70 : void
71 {
72 $agent = $this->getRelevantAgent($input);
73
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}.");
78 return;
79 }
80 $migration = $migrations[$migration_name];
81
82 $steps = (int)$input->getOption('steps');
83
84 switch ($steps) {
86 $io->text("Determined infinite steps to run.");
87 break;
88 case 0:
89 $steps = $migration->getDefaultAmountOfStepsPerRun();
90 $io->text("no --steps option found, fallback to default amount of steps of migration. ($steps)");
91 break;
92 default:
93 $io->text("Determined $steps step(s) to run.");
94 break;
95
96 }
97 $objective = new Objective\MigrationObjective($migration, $steps);
98
99 $env = new ArrayEnvironment([
101 ]);
102
103 $preconditions = $migration->getPreconditions($env);
104 if (count($preconditions) > 0) {
105 $objective = new Objective\ObjectiveWithPreconditions(
106 $objective,
108 );
109 }
110 $steps_text = $steps === Migration::INFINITE ? 'all' : (string)$steps;
111 $io->inform("Preparing Environment for {$steps_text} steps in {$migration_name}");
112 try {
113 $this->achieveObjective($objective, $env, $io);
114 } catch (NoConfirmationException $e) {
115 $io->error("Aborting Migration, a necessary confirmation is missing:\n\n" . $e->getRequestedConfirmation());
116 }
117 }

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

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

+ 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 25 of file MigrateCommand.php.

◆ $preconditions


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