ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilStorageContainersExistingObjective.php
Go to the documentation of this file.
1<?php declare(strict_types=1);
2
6
12{
16 protected $base_dir;
17
19 'fsv2'
20 ];
21
22 public function __construct(array $storage_handler_ids = null)
23 {
24 parent::__construct(StorageHandlerFactory::BASE_DIRECTORY);
25 $this->storage_handler_ids = $storage_handler_ids ?? $this->storage_handler_ids;
26 $this->base_dir = StorageHandlerFactory::BASE_DIRECTORY;
27 }
28
29 protected function buildStorageBasePath(Setup\Environment $environment) : string
30 {
31 $ini = $environment->getResource(Setup\Environment::RESOURCE_ILIAS_INI);
32 $client_id = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_ID);
33
34 $storage_directory_full_path = $ini->readVariable('clients',
35 'datadir') . '/' . $client_id . '/' . $this->base_dir;
36 return $storage_directory_full_path;
37 }
38
39 public function getPreconditions(Setup\Environment $environment) : array
40 {
41 // case if it is a fresh ILIAS installation
42 if ($environment->hasConfigFor("filesystem")) {
43 $config = $environment->getConfigFor("filesystem");
44 return [
45 new \ilFileSystemDirectoriesCreatedObjective($config)
46 ];
47 }
48
49 // case if ILIAS is already installed
50 return [
51 new \ilIniFilesLoadedObjective()
52 ];
53 }
54
55 public function achieve(Setup\Environment $environment) : Setup\Environment
56 {
57 $base_path = $this->buildStorageBasePath($environment);
58 $this->path = $base_path;
59 $environment = parent::achieve($environment);
60
61 foreach ($this->storage_handler_ids as $storage_handler_id) {
62 $this->path = $base_path . '/' . $storage_handler_id;
63 $environment = parent::achieve($environment);
64 }
65 return $environment;
66 }
67
71 public function isApplicable(Setup\Environment $environment) : bool
72 {
73 $base_path = $this->buildStorageBasePath($environment);
74 $this->path = $base_path;
75 if (parent::isApplicable($environment)) {
76 return true;
77 }
78
79 foreach ($this->storage_handler_ids as $storage_handler_id) {
80 $this->path = $base_path . '/' . $storage_handler_id;
81 if (parent::isApplicable($environment)) {
82 return true;
83 }
84 }
85 return false;
86 }
87
88}
An exception for terminatinating execution or to throw for unit testing.
getPreconditions(Setup\Environment $environment)
@inheritdocs
achieve(Setup\Environment $environment)
@inheritdocs
isApplicable(Setup\Environment $environment)
@inheritDoc
An environment holds resources to be used in the setup process.
Definition: Environment.php:12
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