ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilDatabaseDumpedToDirectoryObjective Class Reference
+ Inheritance diagram for ilDatabaseDumpedToDirectoryObjective:
+ Collaboration diagram for ilDatabaseDumpedToDirectoryObjective:

Public Member Functions

 __construct (protected string $target, protected MysqlDumper $dumper)
 
 getHash ()
 Get a hash for this objective.The hash of two objectives must be the same, if they are the same objective, with the same config on the same environment, i.e. if the one is achieved the other is achieved as well because they are the same. More...
 
 getLabel ()
 Get a label that describes this objective. More...
 
 isNotable ()
 Get to know if this is an interesting objective for a human. More...
 
 getPreconditions (Environment $environment)
 Objectives might depend on other objectives.
Exceptions
UnachievableExceptionif the objective is not achievable
Returns
Objective[]
More...
 
 achieve (Environment $environment)
 Objectives can be achieved.They might add resources to the environment when they have been achieved.This method needs to be idempotent for a given environment. That means: if this is executed a second time, nothing new should happen. Or the other way round: if the environment already looks like desired, the objective should not take any further actions when this is called.
Exceptions

LogicException if there are unfullfilled preconditions.

Exceptions

RuntimeException if there are missing resources. More...

 
 isApplicable (Environment $environment)
 @inheritDoc More...
 
 getHash ()
 Get a hash for this objective. More...
 
 getLabel ()
 Get a label that describes this objective. More...
 
 isNotable ()
 Get to know if this is an interesting objective for a human. More...
 
 getPreconditions (Environment $environment)
 Objectives might depend on other objectives. More...
 
 achieve (Environment $environment)
 Objectives can be achieved. More...
 
 isApplicable (Environment $environment)
 Get to know whether the objective is applicable. More...
 

Protected Member Functions

 deleteDirRecursive (string $path)
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilDatabaseDumpedToDirectoryObjective::__construct ( protected string  $target,
protected MysqlDumper  $dumper 
)

Definition at line 26 of file class.ilDatabaseDumpedToDirectoryObjective.php.

27 {
28 }

Member Function Documentation

◆ achieve()

ilDatabaseDumpedToDirectoryObjective::achieve ( Environment  $environment)

Objectives can be achieved.They might add resources to the environment when they have been achieved.This method needs to be idempotent for a given environment. That means: if this is executed a second time, nothing new should happen. Or the other way round: if the environment already looks like desired, the objective should not take any further actions when this is called.

Exceptions

LogicException if there are unfullfilled preconditions.

Exceptions

RuntimeException if there are missing resources.

Implements ILIAS\Setup\Objective.

Definition at line 68 of file class.ilDatabaseDumpedToDirectoryObjective.php.

69 {
70 if (file_exists($this->target)) {
71 $this->deleteDirRecursive($this->target);
72 }
73 mkdir($this->target, 0755);
74
75 $client_ini = $environment->getResource(Environment::RESOURCE_CLIENT_INI);
76 $host = $client_ini->readVariable("db", "host");
77 $user = $client_ini->readVariable("db", "user");
78 $password = $client_ini->readVariable("db", "pass");
79 $name = $client_ini->readVariable("db", "name");
80 $port = $client_ini->readVariable("db", "port");
81
82 $this->dumper->createDump($host, $user, $password, $name, $port, $this->target);
83
84 return $environment;
85 }
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.

References deleteDirRecursive(), and ILIAS\Setup\Environment\getResource().

+ Here is the call graph for this function:

◆ deleteDirRecursive()

ilDatabaseDumpedToDirectoryObjective::deleteDirRecursive ( string  $path)
protected

Definition at line 95 of file class.ilDatabaseDumpedToDirectoryObjective.php.

95 : void
96 {
97 $files = new RecursiveIteratorIterator(
98 new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS),
99 RecursiveIteratorIterator::CHILD_FIRST
100 );
101
102 foreach ($files as $file_info) {
103 if ($file_info->isDir()) {
104 rmdir($file_info->getRealPath());
105 continue;
106 }
107 unlink($file_info->getRealPath());
108 }
109
110 rmdir($path);
111 }
$path
Definition: ltiservices.php:30

References $path.

Referenced by achieve().

+ Here is the caller graph for this function:

◆ getHash()

ilDatabaseDumpedToDirectoryObjective::getHash ( )

Get a hash for this objective.The hash of two objectives must be the same, if they are the same objective, with the same config on the same environment, i.e. if the one is achieved the other is achieved as well because they are the same.

Implements ILIAS\Setup\Objective.

Definition at line 33 of file class.ilDatabaseDumpedToDirectoryObjective.php.

33 : string
34 {
35 return hash("sha256", self::class . $this->target);
36 }

◆ getLabel()

ilDatabaseDumpedToDirectoryObjective::getLabel ( )

Get a label that describes this objective.

Implements ILIAS\Setup\Objective.

Definition at line 41 of file class.ilDatabaseDumpedToDirectoryObjective.php.

41 : string
42 {
43 return "Dump database to $this->target/" . MysqlIfsnopDumper::FILE_NAME;
44 }

References MysqlIfsnopDumper\FILE_NAME.

◆ getPreconditions()

ilDatabaseDumpedToDirectoryObjective::getPreconditions ( Environment  $environment)

Objectives might depend on other objectives.

Exceptions
UnachievableExceptionif the objective is not achievable
Returns
Objective[]

Implements ILIAS\Setup\Objective.

Definition at line 57 of file class.ilDatabaseDumpedToDirectoryObjective.php.

◆ isApplicable()

ilDatabaseDumpedToDirectoryObjective::isApplicable ( Environment  $environment)

@inheritDoc

Implements ILIAS\Setup\Objective.

Definition at line 90 of file class.ilDatabaseDumpedToDirectoryObjective.php.

90 : bool
91 {
92 return is_writable(pathinfo($this->target, PATHINFO_DIRNAME));
93 }

◆ isNotable()

ilDatabaseDumpedToDirectoryObjective::isNotable ( )

Get to know if this is an interesting objective for a human.

Implements ILIAS\Setup\Objective.

Definition at line 49 of file class.ilDatabaseDumpedToDirectoryObjective.php.

49 : bool
50 {
51 return true;
52 }

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