@@ -31,63 +31,63 @@ |
||
| 31 | 31 | use OCP\WorkflowEngine\IFileCheck; |
| 32 | 32 | |
| 33 | 33 | class FileName extends AbstractStringCheck implements IFileCheck { |
| 34 | - use TFileCheck; |
|
| 34 | + use TFileCheck; |
|
| 35 | 35 | |
| 36 | - /** @var IRequest */ |
|
| 37 | - protected $request; |
|
| 38 | - /** @var IMountManager */ |
|
| 39 | - private $mountManager; |
|
| 36 | + /** @var IRequest */ |
|
| 37 | + protected $request; |
|
| 38 | + /** @var IMountManager */ |
|
| 39 | + private $mountManager; |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * @param IL10N $l |
|
| 43 | - * @param IRequest $request |
|
| 44 | - */ |
|
| 45 | - public function __construct(IL10N $l, IRequest $request, IMountManager $mountManager) { |
|
| 46 | - parent::__construct($l); |
|
| 47 | - $this->request = $request; |
|
| 48 | - $this->mountManager = $mountManager; |
|
| 49 | - } |
|
| 41 | + /** |
|
| 42 | + * @param IL10N $l |
|
| 43 | + * @param IRequest $request |
|
| 44 | + */ |
|
| 45 | + public function __construct(IL10N $l, IRequest $request, IMountManager $mountManager) { |
|
| 46 | + parent::__construct($l); |
|
| 47 | + $this->request = $request; |
|
| 48 | + $this->mountManager = $mountManager; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @return string |
|
| 53 | - */ |
|
| 54 | - protected function getActualValue(): string { |
|
| 55 | - $fileName = $this->path === null ? '' : basename($this->path); |
|
| 56 | - if ($fileName === '' && (!$this->storage->isLocal() || $this->storage->instanceOfStorage(Local::class))) { |
|
| 57 | - // Return the mountpoint name of external storages that are not mounted as user home |
|
| 58 | - $mountPoints = $this->mountManager->findByStorageId($this->storage->getId()); |
|
| 59 | - if (empty($mountPoints) || $mountPoints[0]->getMountType() !== 'external') { |
|
| 60 | - return $fileName; |
|
| 61 | - } |
|
| 62 | - $mountPointPath = rtrim($mountPoints[0]->getMountPoint(), '/'); |
|
| 63 | - $mountPointPieces = explode('/', $mountPointPath); |
|
| 64 | - $mountPointName = array_pop($mountPointPieces); |
|
| 65 | - if (!empty($mountPointName) && $mountPointName !== 'files' && count($mountPointPieces) !== 2) { |
|
| 66 | - return $mountPointName; |
|
| 67 | - } |
|
| 68 | - } |
|
| 69 | - return $fileName; |
|
| 70 | - } |
|
| 51 | + /** |
|
| 52 | + * @return string |
|
| 53 | + */ |
|
| 54 | + protected function getActualValue(): string { |
|
| 55 | + $fileName = $this->path === null ? '' : basename($this->path); |
|
| 56 | + if ($fileName === '' && (!$this->storage->isLocal() || $this->storage->instanceOfStorage(Local::class))) { |
|
| 57 | + // Return the mountpoint name of external storages that are not mounted as user home |
|
| 58 | + $mountPoints = $this->mountManager->findByStorageId($this->storage->getId()); |
|
| 59 | + if (empty($mountPoints) || $mountPoints[0]->getMountType() !== 'external') { |
|
| 60 | + return $fileName; |
|
| 61 | + } |
|
| 62 | + $mountPointPath = rtrim($mountPoints[0]->getMountPoint(), '/'); |
|
| 63 | + $mountPointPieces = explode('/', $mountPointPath); |
|
| 64 | + $mountPointName = array_pop($mountPointPieces); |
|
| 65 | + if (!empty($mountPointName) && $mountPointName !== 'files' && count($mountPointPieces) !== 2) { |
|
| 66 | + return $mountPointName; |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | + return $fileName; |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * @param string $operator |
|
| 74 | - * @param string $checkValue |
|
| 75 | - * @param string $actualValue |
|
| 76 | - * @return bool |
|
| 77 | - */ |
|
| 78 | - protected function executeStringCheck($operator, $checkValue, $actualValue): bool { |
|
| 79 | - if ($operator === 'is' || $operator === '!is') { |
|
| 80 | - $checkValue = mb_strtolower($checkValue); |
|
| 81 | - $actualValue = mb_strtolower($actualValue); |
|
| 82 | - } |
|
| 83 | - return parent::executeStringCheck($operator, $checkValue, $actualValue); |
|
| 84 | - } |
|
| 72 | + /** |
|
| 73 | + * @param string $operator |
|
| 74 | + * @param string $checkValue |
|
| 75 | + * @param string $actualValue |
|
| 76 | + * @return bool |
|
| 77 | + */ |
|
| 78 | + protected function executeStringCheck($operator, $checkValue, $actualValue): bool { |
|
| 79 | + if ($operator === 'is' || $operator === '!is') { |
|
| 80 | + $checkValue = mb_strtolower($checkValue); |
|
| 81 | + $actualValue = mb_strtolower($actualValue); |
|
| 82 | + } |
|
| 83 | + return parent::executeStringCheck($operator, $checkValue, $actualValue); |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - public function supportedEntities(): array { |
|
| 87 | - return [ File::class ]; |
|
| 88 | - } |
|
| 86 | + public function supportedEntities(): array { |
|
| 87 | + return [ File::class ]; |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - public function isAvailableForScope(int $scope): bool { |
|
| 91 | - return true; |
|
| 92 | - } |
|
| 90 | + public function isAvailableForScope(int $scope): bool { |
|
| 91 | + return true; |
|
| 92 | + } |
|
| 93 | 93 | } |