ILIAS  release_8 Revision v8.24
InitResourceStorage.php
Go to the documentation of this file.
1<?php
2
38
43{
44 public const D_SERVICE = 'resource_storage';
45 public const D_REPOSITORIES = self::D_SERVICE . '.repositories';
46 public const D_STORAGE_HANDLERS = self::D_SERVICE . '.storage_handlers';
47 public const D_BUILDER = self::D_SERVICE . '.resource_builder';
48 public const D_REPOSITORY_PRELOADER = self::D_SERVICE . '.repository_preloader';
49 public const D_SOURCE_BUILDER = self::D_SERVICE . '.source_builder';
50 public const D_LOCK_HANDLER = self::D_SERVICE . '.lock_handler';
51 public const D_FILENAME_POLICY = self::D_SERVICE . '.filename_policy';
52 public const D_STREAM_ACCESS = self::D_SERVICE . '.stream_access';
53
59 {
62 return new ResourceBuilder(
63 $c[self::D_STORAGE_HANDLERS],
64 $c[self::D_REPOSITORIES],
65 $c[self::D_LOCK_HANDLER],
66 $c[self::D_STREAM_ACCESS],
67 $c[self::D_FILENAME_POLICY],
68 );
69 };
70 return $c[self::D_BUILDER];
71 }
72
73 public function init(\ILIAS\DI\Container $c): void
74 {
75 $base_dir = $this->buildBasePath();
76
77 // DB Repositories
78 $c[self::D_REPOSITORIES] = static function (Container $c): Repositories {
79 return new Repositories(
80 new RevisionDBRepository($c->database()),
81 new ResourceDBRepository($c->database()),
82 new CollectionDBRepository($c->database()),
83 new InformationDBRepository($c->database()),
84 new StakeholderDBRepository($c->database())
85 );
86 };
87
88 // Repository Preloader
89 $c[self::D_REPOSITORY_PRELOADER] = static function (Container $c) {
90 return new DBRepositoryPreloader(
91 $c->database(),
92 $c[self::D_REPOSITORIES]
93 );
94 };
95
96 // Lock Handler
97 $c[self::D_LOCK_HANDLER] = static function (Container $c): LockHandler {
98 return new LockHandlerilDB($c->database());
99 };
100
101 // Storage Handlers
102 $c[self::D_STORAGE_HANDLERS] = static function (Container $c) use ($base_dir): StorageHandlerFactory {
103 return new StorageHandlerFactory([
104 new MaxNestingFileSystemStorageHandler($c['filesystem.storage'], Location::STORAGE),
105 new FileSystemStorageHandler($c['filesystem.storage'], Location::STORAGE)
106 ], $base_dir);
107 };
108
109 // Source Builder for Consumers
110 $c[self::D_SOURCE_BUILDER] = static function (Container $c): ?SrcBuilder {
111 return null;
112 };
113
114 // Filename Policy for Consumers
116 if ($c->isDependencyAvailable('settings') && $c->isDependencyAvailable('clientIni')) {
117 return new ilFileServicesPolicy($c->fileServiceSettings());
118 }
119 return new NoneFileNamePolicy();
120 };
121
122 // Stream Access for Consumers and internal Usage
123 $c[self::D_STREAM_ACCESS] = static function (Container $c) use ($base_dir): StreamAccess {
124 return new StreamAccess(
125 $base_dir,
126 $c[self::D_STORAGE_HANDLERS]
127 );
128 };
129
130 //
131 // IRSS
132 //
133 $c[self::D_SERVICE] = static function (Container $c): \ILIAS\ResourceStorage\Services {
134 return new \ILIAS\ResourceStorage\Services(
135 $c[self::D_STORAGE_HANDLERS],
136 $c[self::D_REPOSITORIES],
137 $c[self::D_LOCK_HANDLER],
138 $c[self::D_FILENAME_POLICY],
139 $c[self::D_STREAM_ACCESS],
140 $c[self::D_SOURCE_BUILDER],
141 $c[self::D_REPOSITORY_PRELOADER],
142 );
143 };
144 }
145
146 protected function buildBasePath(): string
147 {
148 return (defined('ILIAS_DATA_DIR') && defined('CLIENT_ID'))
149 ? rtrim(ILIAS_DATA_DIR, "/") . "/" . CLIENT_ID
150 : '-';
151 }
152}
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:32
Responsible for loading the Resource Storage into the dependency injection container of ILIAS.
getResourceBuilder(\ILIAS\DI\Container $c)
init(\ILIAS\DI\Container $c)
Class ilFileServicesPolicy.
$c
Definition: cli.php:38
const CLIENT_ID
Definition: constants.php:41
const ILIAS_DATA_DIR
Definition: constants.php:44
Interface Location.
Definition: Location.php:30
Class HTTPServicesTest.
Class ChatMainBarProvider \MainMenu\Provider.