ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilDatabaseUpdateStep.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2019 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
8
17{
21 protected $class_name;
22
26 protected $method_name;
27
28 public function __construct(
30 int $num,
32 ) {
33 $this->class_name = get_class($parent);
34 $this->method_name = \ilDatabaseUpdateSteps::STEP_METHOD_PREFIX . $num;
36 function (Environment $env) use ($parent, $num) {
37 $db = $env->getResource(Environment::RESOURCE_DATABASE);
38 $log = $env->getResource(\ilDatabaseUpdateStepExecutionLog::class);
39 if ($log) {
40 $log->started($this->class_name, $num);
41 }
42 call_user_func([$parent, $this->method_name], $db);
43 if ($log) {
44 $log->finished($this->class_name, $num);
45 }
46 },
47 "Database update step {$this->class_name}::{$this->method_name}",
48 false,
49 ...$preconditions
50 );
51 }
52
53
57 public function getHash() : string
58 {
59 return hash(
60 "sha256",
61 $this->class_name . "::" . $this->method_name
62 );
63 }
64}
An exception for terminatinating execution or to throw for unit testing.
A callable objective wraps a callable into an objective.
This encapsulate one database update step which is a method on some ilDatabaseUpdateSteps-object.
__construct(ilDatabaseUpdateSteps $parent, int $num, Objective ... $preconditions)
This base-class simplifies the creation of (consecutive) database updates.
An environment holds resources to be used in the setup process.
Definition: Environment.php:12
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
An objective is a desired state of the system that is supposed to be created by the setup.
Definition: Objective.php:15
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$log
Definition: result.php:15