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