ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
SelectOptionsMigration.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use ILIAS\Setup;
26
28{
29 protected \ilDBInterface $db;
30
31 public function getLabel(): string
32 {
33 return "Grants each select option a permanent ID.";
34 }
35
37 {
39 }
40
41 public function getPreconditions(Environment $environment): array
42 {
43 return [
44 new \ilIniFilesLoadedObjective(),
45 new \ilDatabaseInitializedObjective(),
46 new \ilDatabaseUpdatedObjective(),
47 ];
48 }
49
50 public function prepare(Environment $environment): void
51 {
52 $this->db = $environment->getResource(Environment::RESOURCE_DATABASE);
53 }
54
55 public function step(Environment $environment): void
56 {
57 $res = $this->db->manipulate(
58 'UPDATE adv_mdf_enum SET position = idx WHERE position IS NULL LIMIT 1'
59 );
60 }
61
62 public function getRemainingAmountOfSteps(): int
63 {
64 $res = $this->db->query(
65 'SELECT COUNT(*) AS count FROM adv_mdf_enum WHERE position IS NULL'
66 );
67
68 $row = $this->db->fetchAssoc($res);
69 return (int) $row['count'];
70 }
71}
step(Environment $environment)
Run one step of the migration.
getPreconditions(Environment $environment)
Objectives the migration depend on.
getRemainingAmountOfSteps()
Count up how many "things" need to be migrated.
prepare(Environment $environment)
Prepare the migration by means of some environment.
getDefaultAmountOfStepsPerRun()
Tell the default amount of steps to be executed for one run of the migration.
An environment holds resources to be used in the setup process.
Definition: Environment.php:28
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
A migration is a potentially long lasting operation that can be broken into discrete steps.
Definition: Migration.php:29
$res
Definition: ltiservices.php:69
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: class.Agent.php:19
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...