ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ILIAS\Setup\Objective\ClientIdReadObjective Class Reference

Read the client id of the installation from the data directory. More...

+ Inheritance diagram for ILIAS\Setup\Objective\ClientIdReadObjective:
+ Collaboration diagram for ILIAS\Setup\Objective\ClientIdReadObjective:

Public Member Functions

 getHash ()
 Uses hashed Path. More...
 
 getLabel ()
 
 isNotable ()
 Defaults to 'true'. More...
 
 getPreconditions (Setup\Environment $environment)
 
 achieve (Setup\Environment $environment)
 
 isApplicable (Setup\Environment $environment)
 
- Public Member Functions inherited from ILIAS\Setup\Objective
 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

 getDataDirectoryPath ()
 
 scanDirectory (string $path)
 
 isDirectory (string $path)
 

Detailed Description

Read the client id of the installation from the data directory.

ATTENTION: This might be placed better in some service, rather then being located here in the Setup-library. Currently I don't know where, though. Maybe we also might be able to remove this altogether if the multi-client code has been removed.

Definition at line 17 of file ClientIdReadObjective.php.

Member Function Documentation

◆ achieve()

ILIAS\Setup\Objective\ClientIdReadObjective::achieve ( Setup\Environment  $environment)

Definition at line 58 of file ClientIdReadObjective.php.

References $c, $client_id, ILIAS\Setup\Objective\ClientIdReadObjective\getDataDirectoryPath(), ILIAS_VERSION_NUMERIC, ILIAS\Setup\Objective\ClientIdReadObjective\isDirectory(), ILIAS\Setup\Environment\RESOURCE_CLIENT_ID, and ILIAS\Setup\Objective\ClientIdReadObjective\scanDirectory().

58  : Setup\Environment
59  {
60  $dir = $this->getDataDirectoryPath();
61  $candidates = array_filter(
62  $this->scanDirectory($dir),
63  function ($c) use ($dir) {
64  if ($c == "." || $c == "..") {
65  return false;
66  }
67  return $this->isDirectory($dir . "/" . $c);
68  }
69  );
70 
71  if (count($candidates) == 0) {
72  throw new Setup\UnachievableException(
73  "There are no directories in the webdata-dir at '$dir'. " .
74  "Probably ILIAS is not installed."
75  );
76  }
77 
78  if (count($candidates) != 1) {
79  $ilias_version = ILIAS_VERSION_NUMERIC;
80 
81  throw new Setup\UnachievableException(
82  "There is more than one directory in the webdata-dir at '$dir'. " .
83  "Probably this is an ILIAS installation that uses clients. Clients " .
84  "are not supported anymore since ILIAS $ilias_version " .
85  "(see: https://docu.ilias.de/goto.php?target=wiki_1357_Setup_-_Abandon_Multi_Client)"
86  );
87  }
88 
89  $client_id = array_shift($candidates);
90  return $environment->withResource(Setup\Environment::RESOURCE_CLIENT_ID, $client_id);
91  }
$c
Definition: cli.php:37
const ILIAS_VERSION_NUMERIC
$client_id
Definition: webdav.php:17
+ Here is the call graph for this function:

◆ getDataDirectoryPath()

ILIAS\Setup\Objective\ClientIdReadObjective::getDataDirectoryPath ( )
protected

Definition at line 93 of file ClientIdReadObjective.php.

Referenced by ILIAS\Setup\Objective\ClientIdReadObjective\achieve().

93  : string
94  {
95  return dirname(__DIR__, 3) . "/data";
96  }
+ Here is the caller graph for this function:

◆ getHash()

ILIAS\Setup\Objective\ClientIdReadObjective::getHash ( )

Uses hashed Path.

Implements ILIAS\Setup\Objective.

Definition at line 24 of file ClientIdReadObjective.php.

24  : string
25  {
26  return hash("sha256", self::class);
27  }

◆ getLabel()

ILIAS\Setup\Objective\ClientIdReadObjective::getLabel ( )

Implements ILIAS\Setup\Objective.

Definition at line 32 of file ClientIdReadObjective.php.

32  : string
33  {
34  return "Read client-id from data-directory.";
35  }

◆ getPreconditions()

ILIAS\Setup\Objective\ClientIdReadObjective::getPreconditions ( Setup\Environment  $environment)

Definition at line 50 of file ClientIdReadObjective.php.

50  : array
51  {
52  return [];
53  }

◆ isApplicable()

ILIAS\Setup\Objective\ClientIdReadObjective::isApplicable ( Setup\Environment  $environment)

Definition at line 111 of file ClientIdReadObjective.php.

References ILIAS\Setup\Environment\RESOURCE_CLIENT_ID.

111  : bool
112  {
113  return $environment->getResource(Setup\Environment::RESOURCE_CLIENT_ID) === null;
114  }

◆ isDirectory()

ILIAS\Setup\Objective\ClientIdReadObjective::isDirectory ( string  $path)
protected

Definition at line 103 of file ClientIdReadObjective.php.

Referenced by ILIAS\Setup\Objective\ClientIdReadObjective\achieve().

103  : bool
104  {
105  return is_dir($path);
106  }
+ Here is the caller graph for this function:

◆ isNotable()

ILIAS\Setup\Objective\ClientIdReadObjective::isNotable ( )

Defaults to 'true'.

Implements ILIAS\Setup\Objective.

Definition at line 42 of file ClientIdReadObjective.php.

42  : bool
43  {
44  return false;
45  }

◆ scanDirectory()

ILIAS\Setup\Objective\ClientIdReadObjective::scanDirectory ( string  $path)
protected

Definition at line 98 of file ClientIdReadObjective.php.

Referenced by ILIAS\Setup\Objective\ClientIdReadObjective\achieve().

98  : array
99  {
100  return scandir($path);
101  }
+ Here is the caller graph for this function:

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