ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
class.ilFileSystemClientDirectoryRenamedObjective.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 use ILIAS\Setup;
22 
23 class ilFileSystemClientDirectoryRenamedObjective implements Setup\Objective
24 {
25  public const DEFAULT_CLIENT_ID = "default";
26 
27  protected string $path;
28 
29  public function __construct(string $path)
30  {
31  $this->path = $path;
32  }
33 
34  public function getHash(): string
35  {
36  return hash("sha256", self::class) . $this->path;
37  }
38 
39  public function getLabel(): string
40  {
41  return "Switch client names for export/import";
42  }
43 
44  public function isNotable(): bool
45  {
46  return true;
47  }
48 
49  public function getPreconditions(Setup\Environment $environment): array
50  {
51  return [
53  ];
54  }
55 
56  public function achieve(Setup\Environment $environment): Setup\Environment
57  {
58  $client_id = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_ID);
59 
60  $old_name = $this->path . DIRECTORY_SEPARATOR . $client_id;
61  $new_name = $this->path . DIRECTORY_SEPARATOR . self::DEFAULT_CLIENT_ID;
62 
63  if ($environment->hasConfigFor(Setup\CLI\InstallCommand::IMPORT)) {
64  $old_name = $this->path . DIRECTORY_SEPARATOR . self::DEFAULT_CLIENT_ID;
65  $new_name = $this->path . DIRECTORY_SEPARATOR . $client_id;
66  }
67 
68  rename($old_name, $new_name);
69 
70  return $environment;
71  }
72 
76  public function isApplicable(Setup\Environment $environment): bool
77  {
78  return true;
79  }
80 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
An environment holds resources to be used in the setup process.
Definition: Environment.php:27
$client_id
Definition: ltiauth.php:67