ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilFileSystemClientDirectoryRenamedObjective.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
24
26{
27 public const DEFAULT_CLIENT_ID = "default";
28
29 public function __construct(protected string $path)
30 {
31 }
32
33 public function getHash(): string
34 {
35 return hash("sha256", self::class) . $this->path;
36 }
37
38 public function getLabel(): string
39 {
40 return "Switch client names for export/import";
41 }
42
43 public function isNotable(): bool
44 {
45 return true;
46 }
47
48 public function getPreconditions(Environment $environment): array
49 {
50 return [
52 ];
53 }
54
55 public function achieve(Environment $environment): Environment
56 {
57 $client_id = $environment->getResource(Environment::RESOURCE_CLIENT_ID);
58
59 $old_name = $this->path . DIRECTORY_SEPARATOR . $client_id;
60 $new_name = $this->path . DIRECTORY_SEPARATOR . self::DEFAULT_CLIENT_ID;
61
62 if ($environment->hasConfigFor(InstallCommand::IMPORT)) {
63 $old_name = $this->path . DIRECTORY_SEPARATOR . self::DEFAULT_CLIENT_ID;
64 $new_name = $this->path . DIRECTORY_SEPARATOR . $client_id;
65 }
66
67 rename($old_name, $new_name);
68
69 return $environment;
70 }
71
75 public function isApplicable(Environment $environment): bool
76 {
77 return true;
78 }
79}
isNotable()
Get to know if this is an interesting objective for a human.
getPreconditions(Environment $environment)
Objectives might depend on other objectives.
achieve(Environment $environment)
Objectives can be achieved.
An environment holds resources to be used in the setup process.
Definition: Environment.php:28
hasConfigFor(string $component)
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:31
$client_id
Definition: ltiauth.php:67
$path
Definition: ltiservices.php:30