1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
/** |
4
|
|
|
* @copyright Copyright (c) 2018 Daniel Kesselberg <[email protected]> |
5
|
|
|
* |
6
|
|
|
* @license GNU AGPL version 3 or any later version |
7
|
|
|
* |
8
|
|
|
* This program is free software: you can redistribute it and/or modify |
9
|
|
|
* it under the terms of the GNU Affero General Public License as |
10
|
|
|
* published by the Free Software Foundation, either version 3 of the |
11
|
|
|
* License, or (at your option) any later version. |
12
|
|
|
* |
13
|
|
|
* This program is distributed in the hope that it will be useful, |
14
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16
|
|
|
* GNU Affero General Public License for more details. |
17
|
|
|
* |
18
|
|
|
* You should have received a copy of the GNU Affero General Public License |
19
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
20
|
|
|
* |
21
|
|
|
*/ |
22
|
|
|
|
23
|
|
|
namespace OCA\WorkflowEngine\Check; |
24
|
|
|
|
25
|
|
|
use OCA\WorkflowEngine\Entity\File; |
26
|
|
|
use OCP\IL10N; |
27
|
|
|
use OCP\IRequest; |
28
|
|
|
use OCP\WorkflowEngine\IFileCheck; |
29
|
|
|
|
30
|
|
|
class FileName extends AbstractStringCheck implements IFileCheck { |
31
|
|
|
use TFileCheck; |
32
|
|
|
|
33
|
|
|
/** @var IRequest */ |
34
|
|
|
protected $request; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @param IL10N $l |
38
|
|
|
* @param IRequest $request |
39
|
|
|
*/ |
40
|
|
|
public function __construct(IL10N $l, IRequest $request) { |
41
|
|
|
parent::__construct($l); |
42
|
|
|
$this->request = $request; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @return string |
47
|
|
|
*/ |
48
|
|
|
protected function getActualValue(): string { |
49
|
|
|
return basename($this->path); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @param string $operator |
54
|
|
|
* @param string $checkValue |
55
|
|
|
* @param string $actualValue |
56
|
|
|
* @return bool |
57
|
|
|
*/ |
58
|
|
|
protected function executeStringCheck($operator, $checkValue, $actualValue): bool { |
59
|
|
|
if ($operator === 'is' || $operator === '!is') { |
60
|
|
|
$checkValue = mb_strtolower($checkValue); |
61
|
|
|
$actualValue = mb_strtolower($actualValue); |
62
|
|
|
} |
63
|
|
|
return parent::executeStringCheck($operator, $checkValue, $actualValue); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function supportedEntities(): array { |
67
|
|
|
return [ File::class ]; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function isAvailableForScope(int $scope): bool { |
71
|
|
|
return true; |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|