ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Creator.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
28
29class Creator implements CreatorInterface
30{
31 protected const string PLACEHOLDER_TITLE = 'PLACEHOLDER';
32
34 protected PathFactory $path_factory;
36
37 public function __construct(
39 PathFactory $path_factory,
41 ) {
42 $this->manipulator = $manipulator;
43 $this->path_factory = $path_factory;
44 $this->scaffold_provider = $scaffold_provider;
45 }
46
50 public function createSet(
51 string $title,
52 string $description = '',
53 string $language = ''
54 ): SetInterface {
55 $set = $this->scaffold_provider->set();
56
57 $set = $this->prepareTitle($set, $title, $language);
58 $set = $this->prepareDescription($set, $description, $language);
59 $set = $this->prepareLanguage($set, $language);
60
61 return $set;
62 }
63
64 protected function prepareTitle(
65 SetInterface $set,
66 string $title,
67 string $language
68 ): SetInterface {
69 if ($title === '') {
70 $title = self::PLACEHOLDER_TITLE;
71 }
72
73 $set = $this->manipulator->prepareCreateOrUpdate(
74 $set,
75 $this->getPathToTitleString(),
76 $title
77 );
78
79 if ($language === '') {
80 return $set;
81 }
82 return $this->manipulator->prepareCreateOrUpdate(
83 $set,
84 $this->getPathToTitleLanguage(),
85 $language
86 );
87 }
88
89 protected function prepareDescription(
90 SetInterface $set,
91 string $description,
92 string $language
93 ): SetInterface {
94 if ($description === '') {
95 return $set;
96 }
97 $set = $this->manipulator->prepareCreateOrUpdate(
98 $set,
99 $this->getPathToDescriptionString(),
100 $description
101 );
102
103 if ($language === '') {
104 return $set;
105 }
106 return $this->manipulator->prepareCreateOrUpdate(
107 $set,
108 $this->getPathToDescriptionLanguage(),
109 $language
110 );
111 }
112
113 protected function prepareLanguage(
114 SetInterface $set,
115 string $language
116 ): SetInterface {
117 if ($language === '') {
118 return $set;
119 }
120 return $this->manipulator->prepareCreateOrUpdate(
121 $set,
122 $this->getPathToLanguage(),
123 $language
124 );
125 }
126
128 {
129 return $this->path_factory
130 ->custom()
131 ->withNextStep('general')
132 ->withNextStep('title')
133 ->withNextStep('string')
134 ->get();
135 }
136
138 {
139 return $this->path_factory
140 ->custom()
141 ->withNextStep('general')
142 ->withNextStep('title')
143 ->withNextStep('language')
144 ->get();
145 }
146
148 {
149 return $this->path_factory
150 ->custom()
151 ->withNextStep('general')
152 ->withNextStep('description')
153 ->withNextStep('string')
154 ->get();
155 }
156
158 {
159 return $this->path_factory
160 ->custom()
161 ->withNextStep('general')
162 ->withNextStep('description')
163 ->withNextStep('language')
164 ->get();
165 }
166
167 protected function getPathToLanguage(): PathInterface
168 {
169 return $this->path_factory
170 ->custom()
171 ->withNextStep('general')
172 ->withNextStep('language')
173 ->get();
174 }
175}
prepareLanguage(SetInterface $set, string $language)
Definition: Creator.php:113
createSet(string $title, string $description='', string $language='')
If title is empty, a placeholder is used instead.
Definition: Creator.php:50
__construct(ManipulatorInterface $manipulator, PathFactory $path_factory, ScaffoldProviderInterface $scaffold_provider)
Definition: Creator.php:37
prepareDescription(SetInterface $set, string $description, string $language)
Definition: Creator.php:89
ScaffoldProviderInterface $scaffold_provider
Definition: Creator.php:35
prepareTitle(SetInterface $set, string $title, string $language)
Definition: Creator.php:64
if(!file_exists('../ilias.ini.php'))