ILIAS  release_7 Revision v7.30-3-g800a261c036
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 17 of file ClientIdReadObjective.php.

Member Function Documentation

◆ achieve()

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

@inheritdocs

Definition at line 58 of file ClientIdReadObjective.php.

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
An environment holds resources to be used in the setup process.
Definition: Environment.php:12
$client_id
Definition: webdav.php:17

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

+ Here is the call graph for this function:

◆ getDataDirectoryPath()

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

Definition at line 93 of file ClientIdReadObjective.php.

93 : string
94 {
95 return dirname(__DIR__, 3) . "/data";
96 }

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 24 of file ClientIdReadObjective.php.

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

◆ getLabel()

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

@inheritdocs

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)

@inheritdocs

Definition at line 50 of file ClientIdReadObjective.php.

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

◆ isApplicable()

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

@inheritDoc

Definition at line 111 of file ClientIdReadObjective.php.

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

References ILIAS\Setup\Environment\RESOURCE_CLIENT_ID.

◆ isDirectory()

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

Definition at line 103 of file ClientIdReadObjective.php.

103 : bool
104 {
105 return is_dir($path);
106 }

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

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

98 : array
99 {
100 return scandir($path);
101 }

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

+ Here is the caller graph for this function:

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