ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilFileSystemComponentDataDirectoryCreatedObjective.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2020 Nils Haagen <nils.haagen@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
6
8{
9 const DATADIR = 1;
10 const WEBDIR = 2;
11
15 protected $path;
16
20 protected $component_dir;
21
25 protected $base_location;
26
27
28 public function __construct(
29 string $component_dir,
30 int $base_location = self::DATADIR
31 ) {
33
34 $this->component_dir = $component_dir;
35 $this->base_location = $base_location;
36 }
37
41 public function getHash() : string
42 {
43 return hash("sha256", self::class . "::" . $this->component_dir . (string) $this->base_location);
44 }
45
46 protected function buildPath(Setup\Environment $environment) : string
47 {
48 $ini = $environment->getResource(Setup\Environment::RESOURCE_ILIAS_INI);
49 $client_id = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_ID);
50
51 if ($this->base_location === self::DATADIR) {
52 $data_dir = $ini->readVariable('clients', 'datadir');
53 }
54 if ($this->base_location === self::WEBDIR) {
55 $data_dir = dirname(__DIR__, 4) . "/data";
56 }
57
58 $client_data_dir = $data_dir . '/' . $client_id;
59 $new_dir = $client_data_dir . '/' . $this->component_dir;
60 return $new_dir;
61 }
62
63 public function getPreconditions(Setup\Environment $environment) : array
64 {
65 // case if it is a fresh ILIAS installation
66 if ($environment->hasConfigFor("filesystem")) {
67 $config = $environment->getConfigFor("filesystem");
68 return [
70 ];
71 }
72
73 // case if ILIAS is already installed
74 return [
76 ];
77 }
78
79 public function achieve(Setup\Environment $environment) : Setup\Environment
80 {
81 $this->path = $this->buildPath($environment);
82 return parent::achieve($environment);
83 }
84
88 public function isApplicable(Setup\Environment $environment) : bool
89 {
90 $this->path = $this->buildPath($environment);
91 return parent::isApplicable($environment);
92 }
93}
An exception for terminatinating execution or to throw for unit testing.
An environment holds resources to be used in the setup process.
Definition: Environment.php:12
An objective is a desired state of the system that is supposed to be created by the setup.
Definition: Objective.php:15
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:68
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ini
Definition: raiseError.php:4
$client_id
Definition: webdav.php:17