60 $db = $environment->
getResource(Environment::RESOURCE_DATABASE);
61 $ilias_ini = $environment->
getResource(Environment::RESOURCE_ILIAS_INI);
63 $data_dir = $ilias_ini->readVariable(
'clients',
'datadir');
65 if (!defined(
"CLIENT_WEB_DIR")) {
66 define(
"CLIENT_WEB_DIR", dirname(__DIR__, 4) .
"/data/" .
$client_id);
68 if (!defined(
"ILIAS_WEB_DIR")) {
69 define(
"ILIAS_WEB_DIR", dirname(__DIR__, 4));
71 if (!defined(
"CLIENT_ID")) {
75 $this->database = $db;
83 $container[
'filesystem.storage'] =
$f->getLocal($storageConfiguration);
85 $this->resource_builder = $init->getResourceBuilder(
$container);
91 $this->resource_builder,
92 $this->collection_builder,
139 public function moveFilesOfPathToCollection(
140 string $absolute_path,
141 int $resource_owner_id,
142 int $collection_owner_user_id = ResourceCollection::NO_SPECIFIC_OWNER,
143 ?Closure $file_name_callback =
null,
144 ?Closure $revision_name_callback =
null
148 foreach (
new DirectoryIterator($absolute_path) as $file_info) {
149 if (!$file_info->isFile()) {
153 $file_info->getRealPath(),
156 $revision_name_callback
158 if ($resource_id !==
null) {
159 $collection->add($resource_id);
162 if ($collection->count() === 0) {
167 return $collection->getIdentification();
173 string $absolute_base_path,
175 int $resource_owner_id,
176 int $collection_owner_user_id = ResourceCollection::NO_SPECIFIC_OWNER,
177 ?Closure $file_name_callback =
null,
178 ?Closure $revision_name_callback =
null
180 $collection = $this->getCollectionBuilder()->new($collection_owner_user_id);
182 $regex_iterator =
new RecursiveRegexIterator(
183 new RecursiveDirectoryIterator($absolute_base_path),
185 RecursiveRegexIterator::MATCH
188 foreach ($regex_iterator as $file_info) {
189 if (!$file_info->isFile()) {
192 $resource_id = $this->movePathToStorage(
193 $file_info->getRealPath(),
196 $revision_name_callback
198 if ($resource_id !==
null) {
199 $collection->add($resource_id);
202 if ($collection->count() === 0) {
206 if ($this->getCollectionBuilder()->store($collection)) {
207 return $collection->getIdentification();
213 string $absolute_path,
215 ?Closure $file_name_callback =
null,
216 ?Closure $revision_name_callback =
null
220 $open_path = fopen($absolute_path,
'rb');
221 }
catch (Throwable
$e) {
225 if ($open_path ===
false) {
228 $stream = Streams::ofResource($open_path);
231 $revision_title = $revision_name_callback !==
null
232 ? $revision_name_callback(basename($absolute_path))
233 : basename($absolute_path);
235 $file_name = $file_name_callback !==
null
236 ? $file_name_callback(basename($absolute_path))
239 $resource = $this->resource_builder->newFromStream(
252 $resource->addStakeholder($this->stakeholder);
253 $this->resource_builder->store($resource);
255 return $resource->getIdentification();
Customizing of pimple-DIC for ILIAS.
Class FlySystemFilesystemFactory.
Class ResourceCollection.
Class ResourceCollectionIdentification.
Class ResourceIdentification.
Class StandardRepositoryPreloader.
Class CollectionDBRepository.
Responsible for loading the Resource Storage into the dependency injection container of ILIAS.
const D_REPOSITORY_PRELOADER
Class ilResourceStorageMigrationHelper.
movePathToStorage(string $absolute_path, int $owner_user_id, ?Closure $file_name_callback=null, ?Closure $revision_name_callback=null)
static getPreconditions()
CollectionBuilder $collection_builder
__construct(ResourceStakeholder $stakeholder, Environment $environment)
ilResourceStorageMigrationHelper constructor.
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)
ResourceStakeholder $stakeholder
ResourceBuilder $resource_builder
Interface ResourceStakeholder.
An environment holds resources to be used in the setup process.
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.