ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 ()
 @inheritdocs More...
 
 isNotable ()
 Defaults to 'true'. More...
 
 getPreconditions (Setup\Environment $environment)
 @inheritdocs More...
 
 achieve (Setup\Environment $environment)
 @inheritdocs More...
 
 isApplicable (Setup\Environment $environment)
 @inheritDoc More...
 
- Public Member Functions inherited from ILIAS\Setup\Objective
 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

 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)

@inheritdocs

Definition at line 73 of file ClientIdReadObjective.php.

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 }
string $client_id
Definition: class.ilias.php:36
$c
Definition: deliver.php:25
const ILIAS_VERSION_NUMERIC
An environment holds resources to be used in the setup process.
Definition: Environment.php:28

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().

+ Here is the call graph for this function:

◆ getDataDirectoryPath()

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

Definition at line 108 of file ClientIdReadObjective.php.

108 : string
109 {
110 return dirname(__DIR__, 5) . "/public/data";
111 }

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

+ Here is the caller graph for this function:

◆ getHash()

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

Uses hashed Path.

@inheritdocs

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 ( )

@inheritdocs

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)

@inheritdocs

Definition at line 65 of file ClientIdReadObjective.php.

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

◆ isApplicable()

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

@inheritDoc

Definition at line 130 of file ClientIdReadObjective.php.

130 : bool
131 {
132 return $environment->getResource(Setup\Environment::RESOURCE_CLIENT_ID) === null;
133 }

References ILIAS\Setup\Environment\RESOURCE_CLIENT_ID.

◆ isDirectory()

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

Definition at line 122 of file ClientIdReadObjective.php.

122 : bool
123 {
124 return is_dir($path);
125 }
$path
Definition: ltiservices.php:30

References $path.

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

+ Here is the caller graph for this function:

◆ isNotable()

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

Defaults to 'true'.

@inheritdocs

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.

113 : array
114 {
115 if (!$this->isDirectory($path)) {
116 return [];
117 }
118
119 return scandir($path);
120 }

References $path, and ILIAS\Setup\Objective\ClientIdReadObjective\isDirectory().

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

+ 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: