Passed
Pull Request — master (#123)
by
unknown
04:15
created

BaseTask::getSet()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
/**
4
 * (c) Kitodo. Key to digital objects e.V. <[email protected]>
5
 *
6
 * This file is part of the Kitodo and TYPO3 projects.
7
 *
8
 * @license GNU General Public License version 3 or later.
9
 * For the full copyright and license information, please read the
10
 * LICENSE.txt file that was distributed with this source code.
11
 */
12
namespace Kitodo\Dlf\Task;
13
14
use Kitodo\Dlf\Common\Helper;
15
use TYPO3\CMS\Core\Messaging\FlashMessage;
16
use TYPO3\CMS\Scheduler\Task\AbstractTask;
17
18
/**
19
 * Base class for Scheduler task classes.
20
 *
21
 * @package TYPO3
22
 * @subpackage dlf
23
 *
24
 * @access public
25
 */
26
class BaseTask extends AbstractTask
27
{
28
29
    /**
30
     * @access protected
31
     * @var bool
32
     */
33
    protected bool $dryRun = false;
34
35
    /**
36
     * @access protected
37
     * @var string
38
     */
39
    protected string $doc = 'https://';
40
41
    /**
42
     * @access protected
43
     * @var int
44
     */
45
    protected int $lib = - 1;
46
47
    /**
48
     * @access protected
49
     * @var int
50
     */
51
    protected int $pid = - 1;
52
53
    /**
54
     * @access protected
55
     * @var array
56
     */
57
    protected array $coll = [];
58
59
    /**
60
     * @access protected
61
     * @var int
62
     */
63
    protected int $solr = 0;
64
65
    /**
66
     * @access protected
67
     * @var string
68
     */
69
    protected string $owner = '';
70
71
    /**
72
     * @access protected
73
     * @var bool
74
     */
75
    protected bool $all = false;
76
77
    /**
78
     * @access protected
79
     * @var string
80
     */
81
    protected string $from = '';
82
83
    /**
84
     * @access protected
85
     * @var string
86
     */
87
    protected string $until = '';
88
89
    /**
90
     * @access protected
91
     * @var string
92
     */
93
    protected string $set = '';
94
95
    /**
96
     * @access protected
97
     * @var bool
98
     */
99
    protected bool $softCommit = false;
100
101
    /**
102
     * @access protected
103
     * @var bool
104
     */
105
    protected bool $commit = false;
106
107
    /**
108
     * @access protected
109
     * @var bool
110
     */
111
    protected bool $optimize = false;
112
113
    public function execute()
114
    {
115
        return true;
116
    }
117
118
    /**
119
     *
120
     * @return bool
121
     */
122
    public function isDryRun(): bool
123
    {
124
        return $this->dryRun;
125
    }
126
127
    /**
128
     *
129
     * @param bool $dryRun
130
     */
131
    public function setDryRun(bool $dryRun): void
132
    {
133
        $this->dryRun = $dryRun;
134
    }
135
136
    /**
137
     *
138
     * @return string
139
     */
140
    public function getDoc(): string
141
    {
142
        return $this->doc;
143
    }
144
145
    /**
146
     *
147
     * @param string $doc
148
     */
149
    public function setDoc(string $doc): void
150
    {
151
        $this->doc = $doc;
152
    }
153
154
    /**
155
     *
156
     * @return int
157
     */
158
    public function getLib(): int
159
    {
160
        return $this->lib;
161
    }
162
163
    /**
164
     *
165
     * @param int $lib
166
     */
167
    public function setLib(int $lib): void
168
    {
169
        $this->lib = $lib;
170
    }
171
172
    /**
173
     *
174
     * @return int
175
     */
176
    public function getPid(): int
177
    {
178
        return $this->pid;
179
    }
180
181
    /**
182
     *
183
     * @param int $pid
184
     */
185
    public function setPid(int $pid): void
186
    {
187
        $this->pid = $pid;
188
    }
189
190
    /**
191
     *
192
     * @return array
193
     */
194
    public function getColl(): array
195
    {
196
        return $this->coll;
197
    }
198
199
    /**
200
     *
201
     * @param array $coll
202
     */
203
    public function setColl(array $coll): void
204
    {
205
        $this->coll = $coll;
206
    }
207
208
    /**
209
     *
210
     * @return int
211
     */
212
    public function getSolr(): int
213
    {
214
        return $this->solr;
215
    }
216
217
    /**
218
     *
219
     * @param int $solr
220
     */
221
    public function setSolr(int $solr): void
222
    {
223
        $this->solr = $solr;
224
    }
225
226
    /**
227
     *
228
     * @return string
229
     */
230
    public function getOwner(): string
231
    {
232
        return $this->owner;
233
    }
234
235
    /**
236
     *
237
     * @param string $owner
238
     */
239
    public function setOwner(string $owner): void
240
    {
241
        $this->owner = $owner;
242
    }
243
244
    /**
245
     *
246
     * @return bool
247
     */
248
    public function isAll(): bool
249
    {
250
        return $this->all;
251
    }
252
253
    /**
254
     *
255
     * @param bool $all
256
     */
257
    public function setAll(bool $all): void
258
    {
259
        $this->all = $all;
260
    }
261
262
    /**
263
     *
264
     * @return string
265
     */
266
    public function getFrom(): string
267
    {
268
        return $this->from;
269
    }
270
271
    /**
272
     *
273
     * @param string $from
274
     */
275
    public function setFrom(string $from): void
276
    {
277
        $this->from = $from;
278
    }
279
280
    /**
281
     *
282
     * @return string
283
     */
284
    public function getUntil(): string
285
    {
286
        return $this->until;
287
    }
288
289
    /**
290
     *
291
     * @param string $until
292
     */
293
    public function setUntil(string $until): void
294
    {
295
        $this->until = $until;
296
    }
297
298
    /**
299
     *
300
     * @return string
301
     */
302
    public function getSet(): string
303
    {
304
        return $this->set;
305
    }
306
307
    /**
308
     *
309
     * @param string $set
310
     */
311
    public function setSet(string $set): void
312
    {
313
        $this->set = $set;
314
    }
315
316
    /**
317
     *
318
     * @return bool
319
     */
320
    public function isSoftCommit(): bool
321
    {
322
        return $this->softCommit;
323
    }
324
325
    /**
326
     *
327
     * @param bool $softCommit
328
     */
329
    public function setSoftCommit(bool $softCommit): void
330
    {
331
        $this->softCommit = $softCommit;
332
    }
333
334
    /**
335
     *
336
     * @return bool
337
     */
338
    public function isCommit(): bool
339
    {
340
        return $this->commit;
341
    }
342
343
    /**
344
     *
345
     * @param bool $commit
346
     */
347
    public function setCommit(bool $commit): void
348
    {
349
        $this->commit = $commit;
350
    }
351
352
    /**
353
     *
354
     * @return bool
355
     */
356
    public function isOptimize(): bool
357
    {
358
        return $this->optimize;
359
    }
360
    /**
361
     *
362
     * @param bool $optimize
363
     */
364
    public function setOptimize(bool $optimize): void
365
    {
366
        $this->optimize = $optimize;
367
    }
368
369
    /**
370
     * Generates and adds flash messages based on a string seperated by PHP_EOL.
371
     *
372
     * @access protected
373
     *
374
     * @param string $message Messages seperated by PHP_EOL
375
     * @param int $severity
376
     *
377
     * @return void
378
     */
379
    protected function outputFlashMessages(string $message, int $severity): void
380
    {
381
        $messages = explode(PHP_EOL, $message);
382
383
        foreach ($messages as $message) {
384
            if (empty($message) || (substr_count($message, '=') == strlen($message))) {
385
                continue;
386
            }
387
388
            Helper::addMessage(
389
                $message,
390
                '',
391
                $severity == FlashMessage::ERROR ? FlashMessage::ERROR : FlashMessage::OK,
392
                true,
393
                'core.template.flashMessages'
394
            );
395
        }
396
    }
397
}
398