ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator 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 32 of file ClientIdReadObjective.php.

Member Function Documentation

◆ achieve()

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

Definition at line 73 of file ClientIdReadObjective.php.

References $c, ILIAS\$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().

73  : Setup\Environment
74  {
75  $dir = $this->getDataDirectoryPath();
76  $candidates = array_filter(
77  $this->scanDirectory($dir),
78  function ($c) use ($dir): bool {
79  if ($c === "." || $c === "..") {
80  return false;
81  }
82  return $this->isDirectory($dir . "/" . $c);
83  }
84  );
85 
86  if (count($candidates) === 0) {
87  throw new Setup\UnachievableException(
88  "There are no directories in the webdata-dir at '$dir'. " .
89  "Probably ILIAS is not installed."
90  );
91  }
92 
93  if (count($candidates) !== 1) {
94  $ilias_version = ILIAS_VERSION_NUMERIC;
95 
96  throw new Setup\UnachievableException(
97  "There is more than one directory in the webdata-dir at '$dir'. " .
98  "Probably this is an ILIAS installation that uses clients. Clients " .
99  "are not supported anymore since ILIAS $ilias_version " .
100  "(see: https://docu.ilias.de/goto.php?target=wiki_1357_Setup_-_Abandon_Multi_Client)"
101  );
102  }
103 
104  $client_id = array_shift($candidates);
105  return $environment->withResource(Setup\Environment::RESOURCE_CLIENT_ID, $client_id);
106  }
$c
Definition: deliver.php:25
const ILIAS_VERSION_NUMERIC
string $client_id
Definition: class.ilias.php:36
+ Here is the call graph for this function:

◆ getDataDirectoryPath()

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

Definition at line 108 of file ClientIdReadObjective.php.

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

108  : string
109  {
110  return dirname(__DIR__, 5) . "/public/data";
111  }
+ Here is the caller graph for this function:

◆ getHash()

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

Uses hashed Path.

Implements ILIAS\Setup\Objective.

Definition at line 39 of file ClientIdReadObjective.php.

39  : string
40  {
41  return hash("sha256", self::class);
42  }

◆ getLabel()

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

Implements ILIAS\Setup\Objective.

Definition at line 47 of file ClientIdReadObjective.php.

47  : string
48  {
49  return "Read client-id from data-directory.";
50  }

◆ getPreconditions()

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

Definition at line 65 of file ClientIdReadObjective.php.

65  : array
66  {
67  return [];
68  }

◆ isApplicable()

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

Definition at line 130 of file ClientIdReadObjective.php.

References null, and ILIAS\Setup\Environment\RESOURCE_CLIENT_ID.

130  : bool
131  {
132  return $environment->getResource(Setup\Environment::RESOURCE_CLIENT_ID) === null;
133  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ isDirectory()

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

Definition at line 122 of file ClientIdReadObjective.php.

Referenced by ILIAS\Setup\Objective\ClientIdReadObjective\achieve(), and ILIAS\Setup\Objective\ClientIdReadObjective\scanDirectory().

122  : bool
123  {
124  return is_dir($path);
125  }
$path
Definition: ltiservices.php:29
+ Here is the caller graph for this function:

◆ isNotable()

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

Defaults to 'true'.

Implements ILIAS\Setup\Objective.

Definition at line 57 of file ClientIdReadObjective.php.

57  : bool
58  {
59  return false;
60  }

◆ scanDirectory()

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

Definition at line 113 of file ClientIdReadObjective.php.

References ILIAS\Setup\Objective\ClientIdReadObjective\isDirectory().

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

113  : array
114  {
115  if (!$this->isDirectory($path)) {
116  return [];
117  }
118 
119  return scandir($path);
120  }
$path
Definition: ltiservices.php:29
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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