ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Services.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
32use ILIAS\DI\Container as GlobalContainer;
37use ILIAS\MetaData\Services\Reader\FactoryInterface as ReaderFactoryInterface;
39use ILIAS\MetaData\Services\Manipulator\FactoryInterface as ManipulatorFactoryInterface;
40use ILIAS\MetaData\Services\Manipulator\Factory as ManipulatorFactory;
48
50{
52
53 protected ReaderFactoryInterface $reader_factory;
54 protected ManipulatorFactoryInterface $manipulator_factory;
60
61 public function __construct(GlobalContainer $dic)
62 {
63 $this->internal_services = new InternalServices($dic);
64 }
65
66 public function read(
67 int $obj_id,
68 int $sub_id,
69 string $type,
70 ?PathInterface $limited_to = null
72 if ($sub_id === 0) {
73 $sub_id = $obj_id;
74 }
75
76 $repo = $this->repository();
77 if (isset($limited_to)) {
78 $set = $repo->getMDOnPath($limited_to, $obj_id, $sub_id, $type);
79 } else {
80 $set = $repo->getMD($obj_id, $sub_id, $type);
81 }
82 return $this->readerFactory()->get($set);
83 }
84
85 public function search(): SearcherInterface
86 {
87 if (isset($this->searcher)) {
88 return $this->searcher;
89 }
90 return $this->searcher = new Searcher(
91 $this->internal_services->search()->searchClauseFactory(),
92 $this->internal_services->search()->searchFilterFactory(),
93 $this->internal_services->repository()->repository()
94 );
95 }
96
97 public function manipulate(int $obj_id, int $sub_id, string $type): ManipulatorInterface
98 {
99 if ($sub_id === 0) {
100 $sub_id = $obj_id;
101 }
102
103 $repo = $this->repository();
104 $set = $repo->getMD($obj_id, $sub_id, $type);
105 return $this->manipulatorFactory()->get($set);
106 }
107
109 {
110 if (isset($this->derivation_source_selector)) {
111 return $this->derivation_source_selector;
112 }
113 return $this->derivation_source_selector = new SourceSelector(
114 $this->internal_services->repository()->repository(),
115 new Creator(
116 $this->internal_services->manipulator()->manipulator(),
117 $this->internal_services->paths()->pathFactory(),
118 $this->internal_services->manipulator()->scaffoldProvider()
119 )
120 );
121 }
122
123 public function deleteAll(int $obj_id, int $sub_id, string $type): void
124 {
125 if ($sub_id === 0) {
126 $sub_id = $obj_id;
127 }
128
129 $repo = $this->repository();
130 $repo->deleteAllMD($obj_id, $sub_id, $type);
131 }
132
133 public function paths(): PathsInterface
134 {
135 if (isset($this->paths)) {
136 return $this->paths;
137 }
138 return $this->paths = new Paths(
139 $this->internal_services->paths()->pathFactory()
140 );
141 }
142
144 {
145 if (isset($this->data_helper)) {
146 return $this->data_helper;
147 }
148 return $this->data_helper = new DataHelper(
149 $this->internal_services->dataHelper()->dataHelper(),
150 $this->internal_services->presentation()->data()
151 );
152 }
153
155 {
156 if (isset($this->copyright_helper)) {
157 return $this->copyright_helper;
158 }
159 return $this->copyright_helper = new CopyrightHelper(
161 $this->internal_services->paths()->pathFactory(),
162 $this->internal_services->copyright()->repository(),
163 $this->internal_services->copyright()->identifiersHandler(),
164 $this->internal_services->copyright()->renderer(),
165 $this->internal_services->search()->searchClauseFactory()
166 );
167 }
168
169 protected function readerFactory(): ReaderFactoryInterface
170 {
171 if (isset($this->reader_factory)) {
172 return $this->reader_factory;
173 }
174 return $this->reader_factory = new ReaderFactory(
175 $this->internal_services->paths()->navigatorFactory()
176 );
177 }
178
179 protected function manipulatorFactory(): ManipulatorFactoryInterface
180 {
181 if (isset($this->manipulator_factory)) {
182 return $this->manipulator_factory;
183 }
184 return $this->manipulator_factory = new ManipulatorFactory(
185 $this->internal_services->manipulator()->manipulator(),
186 $this->internal_services->repository()->repository()
187 );
188 }
189
190 protected function repository(): RepositoryInterface
191 {
192 return $this->internal_services->repository()->repository();
193 }
194}
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
copyrightHelper()
The LOM of an object also contains its copyright information, which might consist of a reference to a...
Definition: Services.php:154
search()
Get a searcher, in which you can assemble a search clause and filters, and use these to find objects ...
Definition: Services.php:85
SourceSelectorInterface $derivation_source_selector
Definition: Services.php:57
paths()
Elements in LOM are identified by paths to them from the root.
Definition: Services.php:133
InternalServices $internal_services
Definition: Services.php:51
dataHelper()
The data carried by many LOM elements is in LOM-specific formats.
Definition: Services.php:143
CopyrightHelperInterface $copyright_helper
Definition: Services.php:59
ReaderFactoryInterface $reader_factory
Definition: Services.php:53
read(int $obj_id, int $sub_id, string $type, ?PathInterface $limited_to=null)
Get a reader, which can read out LOM of an ILIAS object.
Definition: Services.php:66
manipulate(int $obj_id, int $sub_id, string $type)
Get a manipulator, which can manipulate the LOM of an ILIAS object.
Definition: Services.php:97
ManipulatorFactoryInterface $manipulator_factory
Definition: Services.php:54
SearcherInterface $searcher
Definition: Services.php:58
DataHelperInterface $data_helper
Definition: Services.php:56
derive()
Derives LOM from a target, for a source.
Definition: Services.php:108
deleteAll(int $obj_id, int $sub_id, string $type)
Delete all LOM of an ILIAS object.
Definition: Services.php:123
__construct(GlobalContainer $dic)
Definition: Services.php:61
$dic
Definition: ltiresult.php:33
if(!file_exists('../ilias.ini.php'))