ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
SelectOptionsMigration.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
23 use 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  {
38  return Migration::INFINITE;
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 }
$res
Definition: ltiservices.php:66
getPreconditions(Environment $environment)
Objectives the migration depend on.
A migration is a potentially long lasting operation that can be broken into discrete steps...
Definition: Migration.php:28
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
prepare(Environment $environment)
Prepare the migration by means of some environment.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: class.Agent.php:19
An environment holds resources to be used in the setup process.
Definition: Environment.php:27
getRemainingAmountOfSteps()
Count up how many "things" need to be migrated.
step(Environment $environment)
Run one step of the migration.
getDefaultAmountOfStepsPerRun()
Tell the default amount of steps to be executed for one run of the migration.