ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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.

53 {
55 $this->agent_finder = $agent_finder;
56 $this->preconditions = $preconditions;
57 }
array $preconditions
var Objective[]
__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 ( )
protected

Definition at line 59 of file MigrateCommand.php.

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

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 
)
protected

Definition at line 73 of file MigrateCommand.php.

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)

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

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

References 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 162 of file MigrateCommand.php.

165 : Environment {
166 $preconditions = $migration->getPreconditions($environment);
167 if ($preconditions !== []) {
168 $objective = new Objective\ObjectiveWithPreconditions(
169 new Objective\NullObjective(),
171 );
172
173 $environment = $this->achieveObjective($objective, $environment);
174 }
175
176 return $environment;
177 }

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

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) {
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 $objective = new Objective\MigrationObjective($migration, $steps);
116
117 $env = new ArrayEnvironment([
119 ]);
120
121 $preconditions = $migration->getPreconditions($env);
122 if ($preconditions !== []) {
123 $objective = new Objective\ObjectiveWithPreconditions(
124 $objective,
126 );
127 }
128 $steps_text = $steps === Migration::INFINITE ? 'all' : (string) $steps;
129 $io->inform("Preparing Environment for {$steps_text} steps in {$migration_name}");
130 try {
131 $this->achieveObjective($objective, $env, $io);
132 } catch (NoConfirmationException $e) {
133 $io->error("Aborting Migration, a necessary confirmation is missing:\n\n" . $e->getRequestedConfirmation());
134 }
135 }

References Vendor\Package\$e, ILIAS\Setup\CLI\MigrateCommand\$preconditions, ILIAS\Setup\CLI\IOWrapper\error(), ILIAS\Setup\CLI\getRelevantAgent(), 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().

+ 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

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