aboutsummaryrefslogtreecommitdiffstats
path: root/apps/workflowengine/lib
diff options
context:
space:
mode:
Diffstat (limited to 'apps/workflowengine/lib')
-rw-r--r--apps/workflowengine/lib/AppInfo/Application.php5
-rw-r--r--apps/workflowengine/lib/BackgroundJobs/Rotate.php5
-rw-r--r--apps/workflowengine/lib/Check/AbstractStringCheck.php13
-rw-r--r--apps/workflowengine/lib/Check/FileMimeType.php37
-rw-r--r--apps/workflowengine/lib/Check/FileName.php13
-rw-r--r--apps/workflowengine/lib/Check/FileSize.php14
-rw-r--r--apps/workflowengine/lib/Check/FileSystemTags.php59
-rw-r--r--apps/workflowengine/lib/Check/RequestRemoteAddress.php14
-rw-r--r--apps/workflowengine/lib/Check/RequestTime.php16
-rw-r--r--apps/workflowengine/lib/Check/RequestURL.php18
-rw-r--r--apps/workflowengine/lib/Check/RequestUserAgent.php10
-rw-r--r--apps/workflowengine/lib/Check/TFileCheck.php3
-rw-r--r--apps/workflowengine/lib/Check/UserGroupMembership.php19
-rw-r--r--apps/workflowengine/lib/Command/Index.php8
-rw-r--r--apps/workflowengine/lib/Controller/AWorkflowController.php17
-rw-r--r--apps/workflowengine/lib/Controller/RequestTimeController.php5
-rw-r--r--apps/workflowengine/lib/Controller/UserWorkflowsController.php21
-rw-r--r--apps/workflowengine/lib/Entity/File.php36
-rw-r--r--apps/workflowengine/lib/Listener/LoadAdditionalSettingsScriptsListener.php9
-rw-r--r--apps/workflowengine/lib/Manager.php43
-rw-r--r--apps/workflowengine/lib/Migration/PopulateNewlyIntroducedDatabaseFields.php12
-rw-r--r--apps/workflowengine/lib/Service/Logger.php2
-rw-r--r--apps/workflowengine/lib/Service/RuleMatcher.php25
-rw-r--r--apps/workflowengine/lib/Settings/ASettings.php33
-rw-r--r--apps/workflowengine/lib/Settings/Section.php13
25 files changed, 161 insertions, 289 deletions
diff --git a/apps/workflowengine/lib/AppInfo/Application.php b/apps/workflowengine/lib/AppInfo/Application.php
index c416db466fe..93b0ca49260 100644
--- a/apps/workflowengine/lib/AppInfo/Application.php
+++ b/apps/workflowengine/lib/AppInfo/Application.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
@@ -51,10 +52,10 @@ class Application extends App implements IBootstrap {
foreach ($configuredEvents as $operationClass => $events) {
foreach ($events as $entityClass => $eventNames) {
- array_map(function (string $eventName) use ($manager, $container, $dispatcher, $logger, $operationClass, $entityClass) {
+ array_map(function (string $eventName) use ($manager, $container, $dispatcher, $logger, $operationClass, $entityClass): void {
$dispatcher->addListener(
$eventName,
- function ($event) use ($manager, $container, $eventName, $logger, $operationClass, $entityClass) {
+ function ($event) use ($manager, $container, $eventName, $logger, $operationClass, $entityClass): void {
$ruleMatcher = $manager->getRuleMatcher();
try {
/** @var IEntity $entity */
diff --git a/apps/workflowengine/lib/BackgroundJobs/Rotate.php b/apps/workflowengine/lib/BackgroundJobs/Rotate.php
index fd3c76c524e..d7984b1226a 100644
--- a/apps/workflowengine/lib/BackgroundJobs/Rotate.php
+++ b/apps/workflowengine/lib/BackgroundJobs/Rotate.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
@@ -8,7 +9,9 @@ namespace OCA\WorkflowEngine\BackgroundJobs;
use OCA\WorkflowEngine\AppInfo\Application;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob;
+use OCP\IConfig;
use OCP\Log\RotationTrait;
+use OCP\Server;
class Rotate extends TimedJob {
use RotationTrait;
@@ -19,7 +22,7 @@ class Rotate extends TimedJob {
}
protected function run($argument) {
- $config = \OC::$server->getConfig();
+ $config = Server::get(IConfig::class);
$default = $config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/flow.log';
$this->filePath = trim((string)$config->getAppValue(Application::APP_ID, 'logfile', $default));
diff --git a/apps/workflowengine/lib/Check/AbstractStringCheck.php b/apps/workflowengine/lib/Check/AbstractStringCheck.php
index 1c544c8c000..d92e9901365 100644
--- a/apps/workflowengine/lib/Check/AbstractStringCheck.php
+++ b/apps/workflowengine/lib/Check/AbstractStringCheck.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
@@ -14,14 +15,12 @@ abstract class AbstractStringCheck implements ICheck {
/** @var array[] Nested array: [Pattern => [ActualValue => Regex Result]] */
protected $matches;
- /** @var IL10N */
- protected $l;
-
/**
* @param IL10N $l
*/
- public function __construct(IL10N $l) {
- $this->l = $l;
+ public function __construct(
+ protected IL10N $l,
+ ) {
}
/**
@@ -70,8 +69,8 @@ abstract class AbstractStringCheck implements ICheck {
throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1);
}
- if (in_array($operator, ['matches', '!matches']) &&
- @preg_match($value, null) === false) {
+ if (in_array($operator, ['matches', '!matches'])
+ && @preg_match($value, null) === false) {
throw new \UnexpectedValueException($this->l->t('The given regular expression is invalid'), 2);
}
}
diff --git a/apps/workflowengine/lib/Check/FileMimeType.php b/apps/workflowengine/lib/Check/FileMimeType.php
index c1e448376c9..a8dfa64528e 100644
--- a/apps/workflowengine/lib/Check/FileMimeType.php
+++ b/apps/workflowengine/lib/Check/FileMimeType.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
@@ -21,21 +22,17 @@ class FileMimeType extends AbstractStringCheck implements IFileCheck {
/** @var array */
protected $mimeType;
- /** @var IRequest */
- protected $request;
-
- /** @var IMimeTypeDetector */
- protected $mimeTypeDetector;
-
/**
* @param IL10N $l
* @param IRequest $request
* @param IMimeTypeDetector $mimeTypeDetector
*/
- public function __construct(IL10N $l, IRequest $request, IMimeTypeDetector $mimeTypeDetector) {
+ public function __construct(
+ IL10N $l,
+ protected IRequest $request,
+ protected IMimeTypeDetector $mimeTypeDetector,
+ ) {
parent::__construct($l);
- $this->request = $request;
- $this->mimeTypeDetector = $mimeTypeDetector;
}
/**
@@ -101,9 +98,9 @@ class FileMimeType extends AbstractStringCheck implements IFileCheck {
return $this->cacheAndReturnMimeType($this->storage->getId(), $this->path, $cacheEntry->getMimeType());
}
- if ($this->storage->file_exists($this->path) &&
- $this->storage->filesize($this->path) &&
- $this->storage->instanceOfStorage(Local::class)
+ if ($this->storage->file_exists($this->path)
+ && $this->storage->filesize($this->path)
+ && $this->storage->instanceOfStorage(Local::class)
) {
$path = $this->storage->getLocalFile($this->path);
$mimeType = $this->mimeTypeDetector->detectContent($path);
@@ -129,12 +126,12 @@ class FileMimeType extends AbstractStringCheck implements IFileCheck {
*/
protected function isWebDAVRequest() {
return substr($this->request->getScriptName(), 0 - strlen('/remote.php')) === '/remote.php' && (
- $this->request->getPathInfo() === '/webdav' ||
- str_starts_with($this->request->getPathInfo() ?? '', '/webdav/') ||
- $this->request->getPathInfo() === '/dav/files' ||
- str_starts_with($this->request->getPathInfo() ?? '', '/dav/files/') ||
- $this->request->getPathInfo() === '/dav/uploads' ||
- str_starts_with($this->request->getPathInfo() ?? '', '/dav/uploads/')
+ $this->request->getPathInfo() === '/webdav'
+ || str_starts_with($this->request->getPathInfo() ?? '', '/webdav/')
+ || $this->request->getPathInfo() === '/dav/files'
+ || str_starts_with($this->request->getPathInfo() ?? '', '/dav/files/')
+ || $this->request->getPathInfo() === '/dav/uploads'
+ || str_starts_with($this->request->getPathInfo() ?? '', '/dav/uploads/')
);
}
@@ -143,8 +140,8 @@ class FileMimeType extends AbstractStringCheck implements IFileCheck {
*/
protected function isPublicWebDAVRequest() {
return substr($this->request->getScriptName(), 0 - strlen('/public.php')) === '/public.php' && (
- $this->request->getPathInfo() === '/webdav' ||
- str_starts_with($this->request->getPathInfo() ?? '', '/webdav/')
+ $this->request->getPathInfo() === '/webdav'
+ || str_starts_with($this->request->getPathInfo() ?? '', '/webdav/')
);
}
diff --git a/apps/workflowengine/lib/Check/FileName.php b/apps/workflowengine/lib/Check/FileName.php
index b4c41811182..4a9d503018f 100644
--- a/apps/workflowengine/lib/Check/FileName.php
+++ b/apps/workflowengine/lib/Check/FileName.php
@@ -18,19 +18,16 @@ use OCP\WorkflowEngine\IFileCheck;
class FileName extends AbstractStringCheck implements IFileCheck {
use TFileCheck;
- /** @var IRequest */
- protected $request;
- /** @var IMountManager */
- private $mountManager;
-
/**
* @param IL10N $l
* @param IRequest $request
*/
- public function __construct(IL10N $l, IRequest $request, IMountManager $mountManager) {
+ public function __construct(
+ IL10N $l,
+ protected IRequest $request,
+ private IMountManager $mountManager,
+ ) {
parent::__construct($l);
- $this->request = $request;
- $this->mountManager = $mountManager;
}
/**
diff --git a/apps/workflowengine/lib/Check/FileSize.php b/apps/workflowengine/lib/Check/FileSize.php
index 51d7d38a7af..5ee03ccc9cf 100644
--- a/apps/workflowengine/lib/Check/FileSize.php
+++ b/apps/workflowengine/lib/Check/FileSize.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
@@ -16,19 +17,14 @@ class FileSize implements ICheck {
/** @var int */
protected $size;
- /** @var IL10N */
- protected $l;
-
- /** @var IRequest */
- protected $request;
-
/**
* @param IL10N $l
* @param IRequest $request
*/
- public function __construct(IL10N $l, IRequest $request) {
- $this->l = $l;
- $this->request = $request;
+ public function __construct(
+ protected IL10N $l,
+ protected IRequest $request,
+ ) {
}
/**
diff --git a/apps/workflowengine/lib/Check/FileSystemTags.php b/apps/workflowengine/lib/Check/FileSystemTags.php
index af1f1930ef0..811571f558a 100644
--- a/apps/workflowengine/lib/Check/FileSystemTags.php
+++ b/apps/workflowengine/lib/Check/FileSystemTags.php
@@ -1,11 +1,12 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\WorkflowEngine\Check;
-use OC\Files\Storage\Wrapper\Wrapper;
+use OC\Files\Storage\Wrapper\Jail;
use OCA\Files_Sharing\SharedStorage;
use OCA\WorkflowEngine\Entity\File;
use OCP\Files\Cache\ICache;
@@ -29,31 +30,13 @@ class FileSystemTags implements ICheck, IFileCheck {
/** @var array */
protected $fileSystemTags;
- /** @var IL10N */
- protected $l;
-
- /** @var ISystemTagManager */
- protected $systemTagManager;
-
- /** @var ISystemTagObjectMapper */
- protected $systemTagObjectMapper;
- /** @var IUserSession */
- protected $userSession;
- /** @var IGroupManager */
- protected $groupManager;
-
public function __construct(
- IL10N $l,
- ISystemTagManager $systemTagManager,
- ISystemTagObjectMapper $systemTagObjectMapper,
- IUserSession $userSession,
- IGroupManager $groupManager
+ protected IL10N $l,
+ protected ISystemTagManager $systemTagManager,
+ protected ISystemTagObjectMapper $systemTagObjectMapper,
+ protected IUserSession $userSession,
+ protected IGroupManager $groupManager,
) {
- $this->l = $l;
- $this->systemTagManager = $systemTagManager;
- $this->systemTagObjectMapper = $systemTagObjectMapper;
- $this->userSession = $userSession;
- $this->groupManager = $groupManager;
}
/**
@@ -133,27 +116,15 @@ class FileSystemTags implements ICheck, IFileCheck {
* @return int[]
*/
protected function getFileIds(ICache $cache, $path, $isExternalStorage) {
- /** @psalm-suppress InvalidArgument */
- if ($this->storage->instanceOfStorage(\OCA\GroupFolders\Mount\GroupFolderStorage::class)) {
- // Special implementation for groupfolder since all groupfolders share the same storage
- // id so add the group folder id in the cache key too.
- $groupFolderStorage = $this->storage;
- if ($this->storage instanceof Wrapper) {
- $groupFolderStorage = $this->storage->getInstanceOfStorage(\OCA\GroupFolders\Mount\GroupFolderStorage::class);
- }
- if ($groupFolderStorage === null) {
- throw new \LogicException('Should not happen: Storage is instance of GroupFolderStorage but no group folder storage found while unwrapping.');
- }
- /**
- * @psalm-suppress UndefinedDocblockClass
- * @psalm-suppress UndefinedInterfaceMethod
- */
- $cacheId = $cache->getNumericStorageId() . '/' . $groupFolderStorage->getFolderId();
+ $cacheId = $cache->getNumericStorageId();
+ if ($this->storage->instanceOfStorage(Jail::class)) {
+ $absolutePath = $this->storage->getUnjailedPath($path);
} else {
- $cacheId = $cache->getNumericStorageId();
+ $absolutePath = $path;
}
- if (isset($this->fileIds[$cacheId][$path])) {
- return $this->fileIds[$cacheId][$path];
+
+ if (isset($this->fileIds[$cacheId][$absolutePath])) {
+ return $this->fileIds[$cacheId][$absolutePath];
}
$parentIds = [];
@@ -168,7 +139,7 @@ class FileSystemTags implements ICheck, IFileCheck {
$parentIds[] = $fileId;
}
- $this->fileIds[$cacheId][$path] = $parentIds;
+ $this->fileIds[$cacheId][$absolutePath] = $parentIds;
return $parentIds;
}
diff --git a/apps/workflowengine/lib/Check/RequestRemoteAddress.php b/apps/workflowengine/lib/Check/RequestRemoteAddress.php
index 909b26c74d6..b6f8fef5aed 100644
--- a/apps/workflowengine/lib/Check/RequestRemoteAddress.php
+++ b/apps/workflowengine/lib/Check/RequestRemoteAddress.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
@@ -11,19 +12,14 @@ use OCP\WorkflowEngine\ICheck;
class RequestRemoteAddress implements ICheck {
- /** @var IL10N */
- protected $l;
-
- /** @var IRequest */
- protected $request;
-
/**
* @param IL10N $l
* @param IRequest $request
*/
- public function __construct(IL10N $l, IRequest $request) {
- $this->l = $l;
- $this->request = $request;
+ public function __construct(
+ protected IL10N $l,
+ protected IRequest $request,
+ ) {
}
/**
diff --git a/apps/workflowengine/lib/Check/RequestTime.php b/apps/workflowengine/lib/Check/RequestTime.php
index 3bb1dba9d93..a49986652b8 100644
--- a/apps/workflowengine/lib/Check/RequestTime.php
+++ b/apps/workflowengine/lib/Check/RequestTime.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
@@ -16,18 +17,13 @@ class RequestTime implements ICheck {
/** @var bool[] */
protected $cachedResults;
- /** @var IL10N */
- protected $l;
-
- /** @var ITimeFactory */
- protected $timeFactory;
-
/**
* @param ITimeFactory $timeFactory
*/
- public function __construct(IL10N $l, ITimeFactory $timeFactory) {
- $this->l = $l;
- $this->timeFactory = $timeFactory;
+ public function __construct(
+ protected IL10N $l,
+ protected ITimeFactory $timeFactory,
+ ) {
}
/**
@@ -67,7 +63,7 @@ class RequestTime implements ICheck {
[$hour1, $minute1] = explode(':', $time1);
$date1 = new \DateTime('now', new \DateTimeZone($timezone1));
$date1->setTimestamp($currentTimestamp);
- $date1->setTime($hour1, $minute1);
+ $date1->setTime((int)$hour1, (int)$minute1);
return $date1->getTimestamp();
}
diff --git a/apps/workflowengine/lib/Check/RequestURL.php b/apps/workflowengine/lib/Check/RequestURL.php
index 43123bddbe9..fb2ac7e8fd5 100644
--- a/apps/workflowengine/lib/Check/RequestURL.php
+++ b/apps/workflowengine/lib/Check/RequestURL.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
@@ -14,16 +15,15 @@ class RequestURL extends AbstractStringCheck {
/** @var ?string */
protected $url;
- /** @var IRequest */
- protected $request;
-
/**
* @param IL10N $l
* @param IRequest $request
*/
- public function __construct(IL10N $l, IRequest $request) {
+ public function __construct(
+ IL10N $l,
+ protected IRequest $request,
+ ) {
parent::__construct($l);
- $this->request = $request;
}
/**
@@ -71,10 +71,10 @@ class RequestURL extends AbstractStringCheck {
return false;
}
return substr($this->request->getScriptName(), 0 - strlen('/remote.php')) === '/remote.php' && (
- $this->request->getPathInfo() === '/webdav' ||
- str_starts_with($this->request->getPathInfo() ?? '', '/webdav/') ||
- $this->request->getPathInfo() === '/dav/files' ||
- str_starts_with($this->request->getPathInfo() ?? '', '/dav/files/')
+ $this->request->getPathInfo() === '/webdav'
+ || str_starts_with($this->request->getPathInfo() ?? '', '/webdav/')
+ || $this->request->getPathInfo() === '/dav/files'
+ || str_starts_with($this->request->getPathInfo() ?? '', '/dav/files/')
);
}
}
diff --git a/apps/workflowengine/lib/Check/RequestUserAgent.php b/apps/workflowengine/lib/Check/RequestUserAgent.php
index 2ae630394fb..572ef567074 100644
--- a/apps/workflowengine/lib/Check/RequestUserAgent.php
+++ b/apps/workflowengine/lib/Check/RequestUserAgent.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
@@ -10,16 +11,15 @@ use OCP\IRequest;
class RequestUserAgent extends AbstractStringCheck {
- /** @var IRequest */
- protected $request;
-
/**
* @param IL10N $l
* @param IRequest $request
*/
- public function __construct(IL10N $l, IRequest $request) {
+ public function __construct(
+ IL10N $l,
+ protected IRequest $request,
+ ) {
parent::__construct($l);
- $this->request = $request;
}
/**
diff --git a/apps/workflowengine/lib/Check/TFileCheck.php b/apps/workflowengine/lib/Check/TFileCheck.php
index 0304a76bd21..a514352e047 100644
--- a/apps/workflowengine/lib/Check/TFileCheck.php
+++ b/apps/workflowengine/lib/Check/TFileCheck.php
@@ -11,6 +11,7 @@ namespace OCA\WorkflowEngine\Check;
use OCA\WorkflowEngine\AppInfo\Application;
use OCA\WorkflowEngine\Entity\File;
use OCP\Files\Node;
+use OCP\Files\NotFoundException;
use OCP\Files\Storage\IStorage;
use OCP\WorkflowEngine\IEntity;
@@ -37,7 +38,7 @@ trait TFileCheck {
}
/**
- * @throws \OCP\Files\NotFoundException
+ * @throws NotFoundException
*/
public function setEntitySubject(IEntity $entity, $subject): void {
if ($entity instanceof File) {
diff --git a/apps/workflowengine/lib/Check/UserGroupMembership.php b/apps/workflowengine/lib/Check/UserGroupMembership.php
index 1c2e535b346..690f9974a49 100644
--- a/apps/workflowengine/lib/Check/UserGroupMembership.php
+++ b/apps/workflowengine/lib/Check/UserGroupMembership.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
@@ -20,24 +21,16 @@ class UserGroupMembership implements ICheck {
/** @var string[] */
protected $cachedGroupMemberships;
- /** @var IUserSession */
- protected $userSession;
-
- /** @var IGroupManager */
- protected $groupManager;
-
- /** @var IL10N */
- protected $l;
-
/**
* @param IUserSession $userSession
* @param IGroupManager $groupManager
* @param IL10N $l
*/
- public function __construct(IUserSession $userSession, IGroupManager $groupManager, IL10N $l) {
- $this->userSession = $userSession;
- $this->groupManager = $groupManager;
- $this->l = $l;
+ public function __construct(
+ protected IUserSession $userSession,
+ protected IGroupManager $groupManager,
+ protected IL10N $l,
+ ) {
}
/**
diff --git a/apps/workflowengine/lib/Command/Index.php b/apps/workflowengine/lib/Command/Index.php
index 395df8c84bb..1fb8cb416b0 100644
--- a/apps/workflowengine/lib/Command/Index.php
+++ b/apps/workflowengine/lib/Command/Index.php
@@ -18,11 +18,9 @@ use Symfony\Component\Console\Output\OutputInterface;
class Index extends Command {
- /** @var Manager */
- private $manager;
-
- public function __construct(Manager $manager) {
- $this->manager = $manager;
+ public function __construct(
+ private Manager $manager,
+ ) {
parent::__construct();
}
diff --git a/apps/workflowengine/lib/Controller/AWorkflowController.php b/apps/workflowengine/lib/Controller/AWorkflowController.php
index a738d55dae8..6395d0d98f6 100644
--- a/apps/workflowengine/lib/Controller/AWorkflowController.php
+++ b/apps/workflowengine/lib/Controller/AWorkflowController.php
@@ -22,22 +22,13 @@ use Psr\Log\LoggerInterface;
abstract class AWorkflowController extends OCSController {
- /** @var Manager */
- protected $manager;
-
- /** @var LoggerInterface */
- private $logger;
-
public function __construct(
$appName,
IRequest $request,
- Manager $manager,
- LoggerInterface $logger
+ protected Manager $manager,
+ private LoggerInterface $logger,
) {
parent::__construct($appName, $request);
-
- $this->manager = $manager;
- $this->logger = $logger;
}
/**
@@ -92,7 +83,7 @@ abstract class AWorkflowController extends OCSController {
array $checks,
string $operation,
string $entity,
- array $events
+ array $events,
): DataResponse {
$context = $this->getScopeContext();
try {
@@ -121,7 +112,7 @@ abstract class AWorkflowController extends OCSController {
array $checks,
string $operation,
string $entity,
- array $events
+ array $events,
): DataResponse {
try {
$context = $this->getScopeContext();
diff --git a/apps/workflowengine/lib/Controller/RequestTimeController.php b/apps/workflowengine/lib/Controller/RequestTimeController.php
index 6c0d9d8d467..4b34f16ce0a 100644
--- a/apps/workflowengine/lib/Controller/RequestTimeController.php
+++ b/apps/workflowengine/lib/Controller/RequestTimeController.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
@@ -6,16 +7,16 @@
namespace OCA\WorkflowEngine\Controller;
use OCP\AppFramework\Controller;
+use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\JSONResponse;
class RequestTimeController extends Controller {
/**
- * @NoAdminRequired
- *
* @param string $search
* @return JSONResponse
*/
+ #[NoAdminRequired]
public function getTimezones($search = '') {
$timezones = \DateTimeZone::listIdentifiers();
diff --git a/apps/workflowengine/lib/Controller/UserWorkflowsController.php b/apps/workflowengine/lib/Controller/UserWorkflowsController.php
index 9be95a2ede9..953ce149233 100644
--- a/apps/workflowengine/lib/Controller/UserWorkflowsController.php
+++ b/apps/workflowengine/lib/Controller/UserWorkflowsController.php
@@ -10,6 +10,7 @@ namespace OCA\WorkflowEngine\Controller;
use OCA\WorkflowEngine\Helper\ScopeContext;
use OCA\WorkflowEngine\Manager;
+use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\Attribute\PasswordConfirmationRequired;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCS\OCSBadRequestException;
@@ -21,9 +22,6 @@ use Psr\Log\LoggerInterface;
class UserWorkflowsController extends AWorkflowController {
- /** @var IUserSession */
- private $session;
-
/** @var ScopeContext */
private $scopeContext;
@@ -31,12 +29,10 @@ class UserWorkflowsController extends AWorkflowController {
$appName,
IRequest $request,
Manager $manager,
- IUserSession $session,
- LoggerInterface $logger
+ private IUserSession $session,
+ LoggerInterface $logger,
) {
parent::__construct($appName, $request, $manager, $logger);
-
- $this->session = $session;
}
/**
@@ -44,47 +40,46 @@ class UserWorkflowsController extends AWorkflowController {
*
* Example: curl -u joann -H "OCS-APIREQUEST: true" "http://my.nc.srvr/ocs/v2.php/apps/workflowengine/api/v1/workflows/user?format=json"
*
- * @NoAdminRequired
* @throws OCSForbiddenException
*/
+ #[NoAdminRequired]
public function index(): DataResponse {
return parent::index();
}
/**
- * @NoAdminRequired
- *
* Example: curl -u joann -H "OCS-APIREQUEST: true" "http://my.nc.srvr/ocs/v2.php/apps/workflowengine/api/v1/workflows/user/OCA\\Workflow_DocToPdf\\Operation?format=json"
* @throws OCSForbiddenException
*/
+ #[NoAdminRequired]
public function show(string $id): DataResponse {
return parent::show($id);
}
/**
- * @NoAdminRequired
* @throws OCSBadRequestException
* @throws OCSForbiddenException
*/
+ #[NoAdminRequired]
#[PasswordConfirmationRequired]
public function create(string $class, string $name, array $checks, string $operation, string $entity, array $events): DataResponse {
return parent::create($class, $name, $checks, $operation, $entity, $events);
}
/**
- * @NoAdminRequired
* @throws OCSBadRequestException
* @throws OCSForbiddenException
*/
+ #[NoAdminRequired]
#[PasswordConfirmationRequired]
public function update(int $id, string $name, array $checks, string $operation, string $entity, array $events): DataResponse {
return parent::update($id, $name, $checks, $operation, $entity, $events);
}
/**
- * @NoAdminRequired
* @throws OCSForbiddenException
*/
+ #[NoAdminRequired]
#[PasswordConfirmationRequired]
public function destroy(int $id): DataResponse {
return parent::destroy($id);
diff --git a/apps/workflowengine/lib/Entity/File.php b/apps/workflowengine/lib/Entity/File.php
index 25cefcd9314..64d552e1737 100644
--- a/apps/workflowengine/lib/Entity/File.php
+++ b/apps/workflowengine/lib/Entity/File.php
@@ -34,50 +34,28 @@ use OCP\WorkflowEngine\IRuleMatcher;
class File implements IEntity, IDisplayText, IUrl, IIcon, IContextPortation {
private const EVENT_NAMESPACE = '\OCP\Files::';
-
- /** @var IL10N */
- protected $l10n;
- /** @var IURLGenerator */
- protected $urlGenerator;
- /** @var IRootFolder */
- protected $root;
/** @var string */
protected $eventName;
/** @var Event */
protected $event;
- /** @var IUserSession */
- private $userSession;
- /** @var ISystemTagManager */
- private $tagManager;
/** @var ?Node */
private $node;
/** @var ?IUser */
private $actingUser = null;
- /** @var IUserManager */
- private $userManager;
/** @var UserMountCache */
private $userMountCache;
- /** @var IMountManager */
- private $mountManager;
public function __construct(
- IL10N $l10n,
- IURLGenerator $urlGenerator,
- IRootFolder $root,
- IUserSession $userSession,
- ISystemTagManager $tagManager,
- IUserManager $userManager,
+ protected IL10N $l10n,
+ protected IURLGenerator $urlGenerator,
+ protected IRootFolder $root,
+ private IUserSession $userSession,
+ private ISystemTagManager $tagManager,
+ private IUserManager $userManager,
UserMountCache $userMountCache,
- IMountManager $mountManager
+ private IMountManager $mountManager,
) {
- $this->l10n = $l10n;
- $this->urlGenerator = $urlGenerator;
- $this->root = $root;
- $this->userSession = $userSession;
- $this->tagManager = $tagManager;
- $this->userManager = $userManager;
$this->userMountCache = $userMountCache;
- $this->mountManager = $mountManager;
}
public function getName(): string {
diff --git a/apps/workflowengine/lib/Listener/LoadAdditionalSettingsScriptsListener.php b/apps/workflowengine/lib/Listener/LoadAdditionalSettingsScriptsListener.php
index 3b5f3f0ae11..e5a03fdcb2e 100644
--- a/apps/workflowengine/lib/Listener/LoadAdditionalSettingsScriptsListener.php
+++ b/apps/workflowengine/lib/Listener/LoadAdditionalSettingsScriptsListener.php
@@ -6,25 +6,18 @@ declare(strict_types=1);
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
+
namespace OCA\WorkflowEngine\Listener;
use OCA\WorkflowEngine\AppInfo\Application;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
-use OCP\Template;
use OCP\Util;
use OCP\WorkflowEngine\Events\LoadSettingsScriptsEvent;
-use function class_exists;
-use function function_exists;
/** @template-implements IEventListener<LoadSettingsScriptsEvent> */
class LoadAdditionalSettingsScriptsListener implements IEventListener {
public function handle(Event $event): void {
- if (!function_exists('style')) {
- // This is hacky, but we need to load the template class
- class_exists(Template::class, true);
- }
-
Util::addScript('core', 'files_fileinfo');
Util::addScript('core', 'files_client');
Util::addScript('core', 'systemtags');
diff --git a/apps/workflowengine/lib/Manager.php b/apps/workflowengine/lib/Manager.php
index 8cd52f4cd64..0f41679789d 100644
--- a/apps/workflowengine/lib/Manager.php
+++ b/apps/workflowengine/lib/Manager.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
@@ -99,7 +100,7 @@ class Manager implements IManager {
->where($query->expr()->neq('events', $query->createNamedParameter('[]'), IQueryBuilder::PARAM_STR))
->groupBy('class', 'entity', $query->expr()->castColumn('events', IQueryBuilder::PARAM_STR));
- $result = $query->execute();
+ $result = $query->executeQuery();
$operations = [];
while ($row = $result->fetch()) {
$eventNames = \json_decode($row['events']);
@@ -145,13 +146,13 @@ class Manager implements IManager {
->where($query->expr()->eq('o.class', $query->createParameter('operationClass')));
$query->setParameters(['operationClass' => $operationClass]);
- $result = $query->execute();
+ $result = $query->executeQuery();
$scopesByOperation[$operationClass] = [];
while ($row = $result->fetch()) {
$scope = new ScopeContext($row['type'], $row['value']);
- if (!$operation->isAvailableForScope((int) $row['type'])) {
+ if (!$operation->isAvailableForScope((int)$row['type'])) {
continue;
}
@@ -180,7 +181,7 @@ class Manager implements IManager {
}
$query->setParameters(['scope' => $scopeContext->getScope(), 'scopeId' => $scopeContext->getScopeId()]);
- $result = $query->execute();
+ $result = $query->executeQuery();
$this->operations[$scopeContext->getHash()] = [];
while ($row = $result->fetch()) {
@@ -191,7 +192,7 @@ class Manager implements IManager {
continue;
}
- if (!$operation->isAvailableForScope((int) $row['scope_type'])) {
+ if (!$operation->isAvailableForScope((int)$row['scope_type'])) {
continue;
}
@@ -221,7 +222,7 @@ class Manager implements IManager {
$query->select('*')
->from('flow_operations')
->where($query->expr()->eq('id', $query->createNamedParameter($id)));
- $result = $query->execute();
+ $result = $query->executeQuery();
$row = $result->fetch();
$result->closeCursor();
@@ -238,7 +239,7 @@ class Manager implements IManager {
array $checkIds,
string $operation,
string $entity,
- array $events
+ array $events,
): int {
$query = $this->connection->getQueryBuilder();
$query->insert('flow_operations')
@@ -250,7 +251,7 @@ class Manager implements IManager {
'entity' => $query->createNamedParameter($entity),
'events' => $query->createNamedParameter(json_encode($events))
]);
- $query->execute();
+ $query->executeStatement();
$this->cacheFactory->createDistributed('flow')->remove('events');
@@ -264,7 +265,7 @@ class Manager implements IManager {
* @param string $operation
* @return array The added operation
* @throws \UnexpectedValueException
- * @throw Exception
+ * @throws Exception
*/
public function addOperation(
string $class,
@@ -273,7 +274,7 @@ class Manager implements IManager {
string $operation,
ScopeContext $scope,
string $entity,
- array $events
+ array $events,
) {
$this->validateOperation($class, $name, $checks, $operation, $scope, $entity, $events);
@@ -313,7 +314,7 @@ class Manager implements IManager {
}
$qb->setParameters(['scope' => $scopeContext->getScope(), 'scopeId' => $scopeContext->getScopeId()]);
- $result = $qb->execute();
+ $result = $qb->executeQuery();
$operations = [];
while (($opId = $result->fetchOne()) !== false) {
@@ -342,7 +343,7 @@ class Manager implements IManager {
string $operation,
ScopeContext $scopeContext,
string $entity,
- array $events
+ array $events,
): array {
if (!$this->canModify($id, $scopeContext)) {
throw new \DomainException('Target operation not within scope');
@@ -393,12 +394,12 @@ class Manager implements IManager {
$this->connection->beginTransaction();
$result = (bool)$query->delete('flow_operations')
->where($query->expr()->eq('id', $query->createNamedParameter($id)))
- ->execute();
+ ->executeStatement();
if ($result) {
$qb = $this->connection->getQueryBuilder();
$result &= (bool)$qb->delete('flow_operations_scope')
->where($qb->expr()->eq('operation_id', $qb->createNamedParameter($id)))
- ->execute();
+ ->executeStatement();
}
$this->connection->commit();
} catch (Exception $e) {
@@ -537,11 +538,11 @@ class Manager implements IManager {
$query->select('*')
->from('flow_checks')
->where($query->expr()->in('id', $query->createNamedParameter($checkIds, IQueryBuilder::PARAM_INT_ARRAY)));
- $result = $query->execute();
+ $result = $query->executeQuery();
while ($row = $result->fetch()) {
- $this->checks[(int) $row['id']] = $row;
- $checks[(int) $row['id']] = $row;
+ $this->checks[(int)$row['id']] = $row;
+ $checks[(int)$row['id']] = $row;
}
$result->closeCursor();
@@ -568,11 +569,11 @@ class Manager implements IManager {
$query->select('id')
->from('flow_checks')
->where($query->expr()->eq('hash', $query->createNamedParameter($hash)));
- $result = $query->execute();
+ $result = $query->executeQuery();
if ($row = $result->fetch()) {
$result->closeCursor();
- return (int) $row['id'];
+ return (int)$row['id'];
}
$query = $this->connection->getQueryBuilder();
@@ -583,7 +584,7 @@ class Manager implements IManager {
'value' => $query->createNamedParameter($value),
'hash' => $query->createNamedParameter($hash),
]);
- $query->execute();
+ $query->executeStatement();
return $query->getLastInsertId();
}
@@ -597,7 +598,7 @@ class Manager implements IManager {
'type' => $query->createNamedParameter($scope->getScope()),
'value' => $query->createNamedParameter($scope->getScopeId()),
]);
- $insertQuery->execute();
+ $insertQuery->executeStatement();
}
public function formatOperation(array $operation): array {
diff --git a/apps/workflowengine/lib/Migration/PopulateNewlyIntroducedDatabaseFields.php b/apps/workflowengine/lib/Migration/PopulateNewlyIntroducedDatabaseFields.php
index 0bc380f8fc6..633d946cd7e 100644
--- a/apps/workflowengine/lib/Migration/PopulateNewlyIntroducedDatabaseFields.php
+++ b/apps/workflowengine/lib/Migration/PopulateNewlyIntroducedDatabaseFields.php
@@ -16,11 +16,9 @@ use OCP\WorkflowEngine\IManager;
class PopulateNewlyIntroducedDatabaseFields implements IRepairStep {
- /** @var IDBConnection */
- private $dbc;
-
- public function __construct(IDBConnection $dbc) {
- $this->dbc = $dbc;
+ public function __construct(
+ private IDBConnection $dbc,
+ ) {
}
public function getName() {
@@ -41,7 +39,7 @@ class PopulateNewlyIntroducedDatabaseFields implements IRepairStep {
$insertQuery = $qb->insert('flow_operations_scope');
while (($id = $ids->fetchOne()) !== false) {
$insertQuery->values(['operation_id' => $qb->createNamedParameter($id), 'type' => IManager::SCOPE_ADMIN]);
- $insertQuery->execute();
+ $insertQuery->executeStatement();
}
}
@@ -55,7 +53,7 @@ class PopulateNewlyIntroducedDatabaseFields implements IRepairStep {
// in case the repair step is executed multiple times for whatever reason.
/** @var IResult $result */
- $result = $selectQuery->execute();
+ $result = $selectQuery->executeQuery();
return $result;
}
}
diff --git a/apps/workflowengine/lib/Service/Logger.php b/apps/workflowengine/lib/Service/Logger.php
index 13ac36659e5..494240bc403 100644
--- a/apps/workflowengine/lib/Service/Logger.php
+++ b/apps/workflowengine/lib/Service/Logger.php
@@ -128,7 +128,7 @@ class Logger {
protected function log(
string $message,
array $context,
- LogContext $logContext
+ LogContext $logContext,
): void {
if (!isset($context['app'])) {
$context['app'] = Application::APP_ID;
diff --git a/apps/workflowengine/lib/Service/RuleMatcher.php b/apps/workflowengine/lib/Service/RuleMatcher.php
index 1712b3b2a32..c95387e14ee 100644
--- a/apps/workflowengine/lib/Service/RuleMatcher.php
+++ b/apps/workflowengine/lib/Service/RuleMatcher.php
@@ -27,39 +27,24 @@ use RuntimeException;
class RuleMatcher implements IRuleMatcher {
- /** @var IUserSession */
- protected $session;
- /** @var IManager */
- protected $manager;
/** @var array */
protected $contexts;
- /** @var IServerContainer */
- protected $container;
/** @var array */
protected $fileInfo = [];
- /** @var IL10N */
- protected $l;
/** @var IOperation */
protected $operation;
/** @var IEntity */
protected $entity;
- /** @var Logger */
- protected $logger;
/** @var string */
protected $eventName;
public function __construct(
- IUserSession $session,
- IServerContainer $container,
- IL10N $l,
- Manager $manager,
- Logger $logger
+ protected IUserSession $session,
+ protected IServerContainer $container,
+ protected IL10N $l,
+ protected Manager $manager,
+ protected Logger $logger,
) {
- $this->session = $session;
- $this->manager = $manager;
- $this->container = $container;
- $this->l = $l;
- $this->logger = $logger;
}
public function setFileInfo(IStorage $storage, string $path, bool $isDir = false): void {
diff --git a/apps/workflowengine/lib/Settings/ASettings.php b/apps/workflowengine/lib/Settings/ASettings.php
index 1cf03376e9f..23e958755de 100644
--- a/apps/workflowengine/lib/Settings/ASettings.php
+++ b/apps/workflowengine/lib/Settings/ASettings.php
@@ -26,30 +26,15 @@ use OCP\WorkflowEngine\IOperation;
use OCP\WorkflowEngine\ISpecificOperation;
abstract class ASettings implements ISettings {
- private IL10N $l10n;
- private string $appName;
- private IEventDispatcher $eventDispatcher;
- protected Manager $manager;
- private IInitialState $initialStateService;
- private IConfig $config;
- private IURLGenerator $urlGenerator;
-
public function __construct(
- string $appName,
- IL10N $l,
- IEventDispatcher $eventDispatcher,
- Manager $manager,
- IInitialState $initialStateService,
- IConfig $config,
- IURLGenerator $urlGenerator
+ private string $appName,
+ private IL10N $l10n,
+ private IEventDispatcher $eventDispatcher,
+ protected Manager $manager,
+ private IInitialState $initialStateService,
+ private IConfig $config,
+ private IURLGenerator $urlGenerator,
) {
- $this->appName = $appName;
- $this->l10n = $l;
- $this->eventDispatcher = $eventDispatcher;
- $this->manager = $manager;
- $this->initialStateService = $initialStateService;
- $this->config = $config;
- $this->urlGenerator = $urlGenerator;
}
abstract public function getScope(): int;
@@ -110,8 +95,8 @@ abstract class ASettings implements ISettings {
/**
* @return int whether the form should be rather on the top or bottom of
- * the admin section. The forms are arranged in ascending order of the
- * priority values. It is required to return a value between 0 and 100.
+ * the admin section. The forms are arranged in ascending order of the
+ * priority values. It is required to return a value between 0 and 100.
*
* E.g.: 70
*/
diff --git a/apps/workflowengine/lib/Settings/Section.php b/apps/workflowengine/lib/Settings/Section.php
index 1e23eee64ee..aa790c9ddcc 100644
--- a/apps/workflowengine/lib/Settings/Section.php
+++ b/apps/workflowengine/lib/Settings/Section.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
@@ -11,18 +12,14 @@ use OCP\IURLGenerator;
use OCP\Settings\IIconSection;
class Section implements IIconSection {
- /** @var IL10N */
- private $l;
- /** @var IURLGenerator */
- private $url;
-
/**
* @param IURLGenerator $url
* @param IL10N $l
*/
- public function __construct(IURLGenerator $url, IL10N $l) {
- $this->url = $url;
- $this->l = $l;
+ public function __construct(
+ private IURLGenerator $url,
+ private IL10N $l,
+ ) {
}
/**