ILIAS  trunk Revision v11.0_alpha-1753-gb21ca8c4367
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilFileSystemComponentDataDirectoryCreatedObjective Class Reference
+ Inheritance diagram for ilFileSystemComponentDataDirectoryCreatedObjective:
+ Collaboration diagram for ilFileSystemComponentDataDirectoryCreatedObjective:

Public Member Functions

 __construct (string $component_dir, protected int $base_location=self::DATADIR)
 
 getHash ()
 Get a hash for this objective. More...
 
 getPreconditions (Environment $environment)
 
 achieve (Environment $environment)
 Objectives can be achieved. More...
 
 isApplicable (Environment $environment)
 
- Public Member Functions inherited from ILIAS\Setup\Objective\DirectoryCreatedObjective
 __construct (string $path, int $permissions=self::DEFAULT_DIRECTORY_PERMISSIONS)
 
 getHash ()
 Uses hashed Path. More...
 
 getLabel ()
 Defaults to "Build $this->getArtifactPath()". More...
 
 isNotable ()
 Defaults to 'true'. More...
 
 getPreconditions (Setup\Environment $environment)
 
 achieve (Setup\Environment $environment)
 
 isApplicable (Setup\Environment $environment)
 

Data Fields

const DATADIR = 1
 
const WEBDIR = 2
 
- Data Fields inherited from ILIAS\Setup\Objective\DirectoryCreatedObjective
const DEFAULT_DIRECTORY_PERMISSIONS = 0755
 

Protected Member Functions

 buildPath (Environment $environment)
 

Protected Attributes

string $component_dir
 
- Protected Attributes inherited from ILIAS\Setup\Objective\DirectoryCreatedObjective
string $path
 
int $permissions
 

Private Member Functions

 checkEnvironment (Environment $environment)
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilFileSystemComponentDataDirectoryCreatedObjective::__construct ( string  $component_dir,
protected int  $base_location = self::DATADIR 
)

Definition at line 31 of file class.ilFileSystemComponentDataDirectoryCreatedObjective.php.

References $component_dir, and ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

Member Function Documentation

◆ achieve()

ilFileSystemComponentDataDirectoryCreatedObjective::achieve ( Environment  $environment)

Objectives can be achieved.

They might add resources to the environment when they have been achieved.

This method needs to be idempotent for a given environment. That means: if this is executed a second time, nothing new should happen. Or the other way round: if the environment already looks like desired, the objective should not take any further actions when this is called.

Exceptions

Implements ILIAS\Setup\Objective.

Definition at line 86 of file class.ilFileSystemComponentDataDirectoryCreatedObjective.php.

References buildPath(), and checkEnvironment().

86  : Environment
87  {
88  if (!$this->checkEnvironment($environment)) {
89  throw new UnachievableException("Environment is not ready for this objective");
90  }
91  $this->path = $this->buildPath($environment);
92  return parent::achieve($environment);
93  }
Signals that some goal won't be achievable by actions of the system ever.
An environment holds resources to be used in the setup process.
Definition: Environment.php:27
+ Here is the call graph for this function:

◆ buildPath()

ilFileSystemComponentDataDirectoryCreatedObjective::buildPath ( Environment  $environment)
protected

Definition at line 46 of file class.ilFileSystemComponentDataDirectoryCreatedObjective.php.

References $client_id, $component_dir, $data_dir, $ini, and ILIAS\Setup\Environment\getResource().

Referenced by achieve(), and isApplicable().

46  : string
47  {
48  $ini = $environment->getResource(Environment::RESOURCE_ILIAS_INI);
49  $client_id = $environment->getResource(Environment::RESOURCE_CLIENT_ID);
50 
51  if ($this->base_location === self::DATADIR) {
52  $data_dir = $ini->readVariable('clients', 'datadir');
53  } elseif ($this->base_location === self::WEBDIR) {
54  $data_dir = dirname(__DIR__, 5) . "/public/data";
55  }
56  if (!isset($data_dir)) {
57  throw new LogicException('cannot determine base directory');
58  }
59 
60  $client_data_dir = $data_dir . '/' . $client_id;
61 
62  return $client_data_dir . '/' . $this->component_dir;
63  }
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
$client_id
Definition: ltiauth.php:66
$ini
Definition: raiseError.php:20
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkEnvironment()

ilFileSystemComponentDataDirectoryCreatedObjective::checkEnvironment ( Environment  $environment)
private

Definition at line 108 of file class.ilFileSystemComponentDataDirectoryCreatedObjective.php.

References ILIAS\Setup\Environment\getResource(), and null.

Referenced by achieve(), and isApplicable().

108  : bool
109  {
110  if (null === $environment->getResource(Environment::RESOURCE_ILIAS_INI)) {
111  return false;
112  }
113  return null !== $environment->getResource(Environment::RESOURCE_CLIENT_ID);
114  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getHash()

ilFileSystemComponentDataDirectoryCreatedObjective::getHash ( )

Get a hash for this objective.

The hash of two objectives must be the same, if they are the same objective, with the same config on the same environment, i.e. if the one is achieved the other is achieved as well because they are the same.

Implements ILIAS\Setup\Objective.

Definition at line 41 of file class.ilFileSystemComponentDataDirectoryCreatedObjective.php.

41  : string
42  {
43  return hash("sha256", self::class . "::" . $this->component_dir . $this->base_location);
44  }

◆ getPreconditions()

ilFileSystemComponentDataDirectoryCreatedObjective::getPreconditions ( Environment  $environment)
Returns
[]|[]

Implements ILIAS\Setup\Objective.

Definition at line 69 of file class.ilFileSystemComponentDataDirectoryCreatedObjective.php.

References ILIAS\Setup\Environment\getConfigFor(), and ILIAS\Setup\Environment\hasConfigFor().

69  : array
70  {
71  // case if it is a fresh ILIAS installation
72  if ($environment->hasConfigFor("filesystem")) {
73  $config = $environment->getConfigFor("filesystem");
74  return [
76  ];
77  }
78 
79  // case if ILIAS is already installed
80  return [
82  ];
83  }
hasConfigFor(string $component)
getConfigFor(string $component)
+ Here is the call graph for this function:

◆ isApplicable()

ilFileSystemComponentDataDirectoryCreatedObjective::isApplicable ( Environment  $environment)

Implements ILIAS\Setup\Objective.

Definition at line 99 of file class.ilFileSystemComponentDataDirectoryCreatedObjective.php.

References buildPath(), and checkEnvironment().

99  : bool
100  {
101  if (!$this->checkEnvironment($environment)) {
102  return false;
103  }
104  $this->path = $this->buildPath($environment);
105  return parent::isApplicable($environment);
106  }
+ Here is the call graph for this function:

Field Documentation

◆ $component_dir

string ilFileSystemComponentDataDirectoryCreatedObjective::$component_dir
protected

◆ DATADIR

const ilFileSystemComponentDataDirectoryCreatedObjective::DATADIR = 1

◆ WEBDIR


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