65 $db = $environment->
getResource(Environment::RESOURCE_DATABASE);
66 $ilias_ini = $environment->
getResource(Environment::RESOURCE_ILIAS_INI);
68 $data_dir = $ilias_ini->readVariable(
'clients',
'datadir');
69 $client_data_dir =
"{$data_dir}/{$client_id}";
70 if (!defined(
"CLIENT_WEB_DIR")) {
71 define(
"CLIENT_WEB_DIR", dirname(__DIR__, 5) .
"/public/data/" .
$client_id);
73 if (!defined(
"ILIAS_WEB_DIR")) {
74 define(
"ILIAS_WEB_DIR",
'public/data');
76 if (!defined(
"CLIENT_ID")) {
79 if (!defined(
"ILIAS_DATA_DIR")) {
83 $this->database = $db;
85 if (!is_writable(
"{$data_dir}/{$client_id}/storage/fsv2")) {
86 throw new Exception(
'storage directory is not writable, abort...');
93 $storageConfiguration =
new LocalConfig($client_data_dir);
95 $container[
'filesystem.storage'] =
$f->getLocal($storageConfiguration);
97 $this->resource_builder = $init->getResourceBuilder(
$container);
98 $this->flavour_builder = $init->getFlavourBuilder(
$container);
107 $this->resource_builder,
108 $this->collection_builder,
140 return $this->stakeholder;
166 ?
int $new_owner_id =
null 168 $resource = $this->manager->getResource($resource_identification);
169 $resource->removeStakeholder($old_stakeholder);
170 $this->repositories->getStakeholderRepository()->deregister($resource_identification, $old_stakeholder);
171 $resource->addStakeholder($new_stakeholder);
172 $this->repositories->getStakeholderRepository()->register($resource_identification, $new_stakeholder);
174 if ($new_owner_id !==
null) {
175 foreach ($resource->getAllRevisionsIncludingDraft() as $revision) {
176 $revision->setOwnerId($new_owner_id);
180 $this->resource_builder->store($resource);
184 public function moveFilesOfPathToCollection(
185 string $absolute_path,
186 int $resource_owner_id,
187 int $collection_owner_user_id = ResourceCollection::NO_SPECIFIC_OWNER,
194 if (!$file_info->isFile()) {
198 $file_info->getRealPath(),
201 $revision_name_callback
203 if ($resource_id !==
null) {
204 $collection->add($resource_id);
209 return $collection->getIdentification();
215 string $absolute_base_path,
217 int $resource_owner_id,
218 int $collection_owner_user_id = ResourceCollection::NO_SPECIFIC_OWNER,
226 foreach ($regex_iterator as $file_info) {
227 if (!$file_info->isFile()) {
231 $file_info->getRealPath(),
234 $revision_name_callback
236 if ($resource_id !==
null) {
237 $collection->add($resource_id);
240 if ($collection->count() === 0) {
245 return $collection->getIdentification();
251 string $absolute_base_path,
253 int $resource_owner_id,
259 foreach ($regex_iterator as $file_info) {
260 if (!$file_info->isFile()) {
264 $file_info->getRealPath(),
267 $revision_name_callback
269 if ($resource_id !==
null) {
278 string $absolute_path,
282 ?
bool $copy_instead_of_move =
false 286 $open_path = fopen($absolute_path,
'rb');
291 if ($open_path ===
false) {
294 $stream = Streams::ofResource($open_path);
297 $revision_title = $revision_name_callback !==
null 298 ? $revision_name_callback(basename($absolute_path))
299 : basename($absolute_path);
301 $file_name = $file_name_callback !==
null 302 ? $file_name_callback(basename($absolute_path))
305 $resource = $this->resource_builder->newFromStream(
314 $copy_instead_of_move ??
false 318 $resource->addStakeholder($this->stakeholder);
319 $this->resource_builder->store($resource);
321 return $resource->getIdentification();
325 string $absolute_path_to_directory,
329 if (!is_dir($absolute_path_to_directory)) {
334 (
new ZipOptions())->withDirectoryHandling(ZipDirectoryHandling::KEEP_STRUCTURE)
336 $zip->addDirectory($absolute_path_to_directory);
338 $zip_stream = $zip->get();
343 $resource = $this->resource_builder->newFromStream(
349 basename($absolute_path_to_directory),
350 basename($absolute_path_to_directory)
357 $resource->addStakeholder($this->stakeholder);
358 $this->resource_builder->store($resource);
360 return $resource->getIdentification();
364 string $absolute_base_path,
365 string $pattern =
'.*' 366 ): RecursiveRegexIterator {
367 return new RecursiveRegexIterator(
370 RecursiveRegexIterator::MATCH
buildRecursivePatternIterator(string $absolute_base_path, string $pattern='.*')
FlavourBuilder $flavour_builder
Class ilResourceStorageDB90.
Class ilStorageContainersExistingObjective.
const D_REPOSITORY_PRELOADER
Responsible for loading the Resource Storage into the dependency injection container of ILIAS...
Class ResourceCollectionIdentification.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Repositories $repositories
moveResourceToNewStakeholderAndOwner(ResourceIdentification $resource_identification, ResourceStakeholder $old_stakeholder, ResourceStakeholder $new_stakeholder, ?int $new_owner_id=null)
Class CollectionDBRepository.
Customizing of pimple-DIC for ILIAS.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
Class ResourceIdentification.
__construct(protected ResourceStakeholder $stakeholder, Environment $environment)
ilResourceStorageMigrationHelper constructor.
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
movePathToStorage(string $absolute_path, int $owner_user_id, ?Closure $file_name_callback=null, ?Closure $revision_name_callback=null, ?bool $copy_instead_of_move=false)
moveDirectoryToContainerResource(string $absolute_path_to_directory, int $owner_user_id,)
moveFirstFileOfPatternToStorage(string $absolute_base_path, string $pattern, int $resource_owner_id, ?Closure $file_name_callback=null, ?Closure $revision_name_callback=null)
An environment holds resources to be used in the setup process.
CollectionBuilder $collection_builder
This class is used to configure the local filesystem adapter.
Interface ResourceStakeholder.
static getPreconditions()
moveFilesOfPatternToCollection(string $absolute_base_path, string $pattern, int $resource_owner_id, int $collection_owner_user_id=ResourceCollection::NO_SPECIFIC_OWNER, ?Closure $file_name_callback=null, ?Closure $revision_name_callback=null)
ResourceBuilder $resource_builder