ILIAS  release_8 Revision v8.24
class.ilStorageContainersExistingObjective.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22use ILIAS\Setup;
24
30{
31 protected string $base_dir = StorageHandlerFactory::BASE_DIRECTORY;
32
36 protected array $storage_handler_ids = [
37 'fsv2'
38 ];
39
40 public function __construct(array $storage_handler_ids = null)
41 {
42 parent::__construct(StorageHandlerFactory::BASE_DIRECTORY);
43 $this->storage_handler_ids = $storage_handler_ids ?? $this->storage_handler_ids;
44 }
45
46 protected function buildStorageBasePath(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 return $ini->readVariable(
51 'clients',
52 'datadir'
53 ) . '/' . $client_id . '/' . $this->base_dir;
54 }
55
59 public function getPreconditions(Setup\Environment $environment): array
60 {
61 // case if it is a fresh ILIAS installation
62 if ($environment->hasConfigFor("filesystem")) {
63 $config = $environment->getConfigFor("filesystem");
64 return [
65 new \ilFileSystemDirectoriesCreatedObjective($config)
66 ];
67 }
68
69 // case if ILIAS is already installed
70 return [
71 new \ilIniFilesLoadedObjective()
72 ];
73 }
74
75 public function achieve(Setup\Environment $environment): Setup\Environment
76 {
77 $base_path = $this->buildStorageBasePath($environment);
78 $this->path = $base_path;
79 $environment = parent::achieve($environment);
80
81 foreach ($this->storage_handler_ids as $storage_handler_id) {
82 $this->path = $base_path . '/' . $storage_handler_id;
83 $environment = parent::achieve($environment);
84 }
85 return $environment;
86 }
87
91 public function isApplicable(Setup\Environment $environment): bool
92 {
93 $base_path = $this->buildStorageBasePath($environment);
94 $this->path = $base_path;
95 if (parent::isApplicable($environment)) {
96 return true;
97 }
98
99 foreach ($this->storage_handler_ids as $storage_handler_id) {
100 $this->path = $base_path . '/' . $storage_handler_id;
101 if (parent::isApplicable($environment)) {
102 return true;
103 }
104 }
105 return false;
106 }
107}
achieve(Setup\Environment $environment)
@inheritdocs
isApplicable(Setup\Environment $environment)
@inheritDoc
An environment holds resources to be used in the setup process.
Definition: Environment.php:28
$client_id
Definition: ltiauth.php:68
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:85
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ini
Definition: raiseError.php:4