ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilStorageContainersExistingObjective.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
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(Environment $environment): string
47  {
48  $ini = $environment->getResource(Environment::RESOURCE_ILIAS_INI);
49  $client_id = $environment->getResource(Environment::RESOURCE_CLIENT_ID);
50  return $ini->readVariable(
51  'clients',
52  'datadir'
53  ) . '/' . $client_id . '/' . $this->base_dir;
54  }
55 
59  #[\Override]
60  public function getPreconditions(Environment $environment): array
61  {
62  // case if it is a fresh ILIAS installation
63  if ($environment->hasConfigFor("filesystem")) {
64  $config = $environment->getConfigFor("filesystem");
65  return [
66  new \ilFileSystemDirectoriesCreatedObjective($config)
67  ];
68  }
69 
70  // case if ILIAS is already installed
71  return [
72  new \ilIniFilesLoadedObjective()
73  ];
74  }
75 
76  #[\Override]
77  public function achieve(Environment $environment): Environment
78  {
79  $base_path = $this->buildStorageBasePath($environment);
80  $this->path = $base_path;
81  $environment = parent::achieve($environment);
82 
83  foreach ($this->storage_handler_ids as $storage_handler_id) {
84  $this->path = $base_path . '/' . $storage_handler_id;
85  $environment = parent::achieve($environment);
86  }
87  return $environment;
88  }
89 
93  #[\Override]
94  public function isApplicable(Environment $environment): bool
95  {
96  $base_path = $this->buildStorageBasePath($environment);
97  $this->path = $base_path;
98  if (parent::isApplicable($environment)) {
99  return true;
100  }
101 
102  foreach ($this->storage_handler_ids as $storage_handler_id) {
103  $this->path = $base_path . '/' . $storage_handler_id;
104  if (parent::isApplicable($environment)) {
105  return true;
106  }
107  }
108  return false;
109  }
110 }
achieve(Environment $environment)
Objectives can be achieved.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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.
An environment holds resources to be used in the setup process.
Definition: Environment.php:27
__construct(Container $dic, ilPlugin $plugin)
$client_id
Definition: ltiauth.php:66
hasConfigFor(string $component)
getConfigFor(string $component)
$ini
Definition: raiseError.php:20