Switch from OC::$server->get to OCP\Server::get
And add a bit more typing to some classes + psalm issues Signed-off-by: Carl Schwan <carl@carlschwan.eu>
This commit is contained in:
committed by
Julius Härtl
parent
2c7708dab1
commit
44481e1c2a
@@ -24,7 +24,6 @@
|
||||
|
||||
namespace OCA\Deck\Service;
|
||||
|
||||
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
|
||||
use OCA\Deck\Activity\ActivityManager;
|
||||
use OCA\Deck\Activity\ChangeSet;
|
||||
use OCA\Deck\AppInfo\Application;
|
||||
@@ -45,37 +44,38 @@ use OCA\Deck\Notification\NotificationHelper;
|
||||
use OCP\AppFramework\Db\DoesNotExistException;
|
||||
use OCP\EventDispatcher\IEventDispatcher;
|
||||
use OCP\IConfig;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\IGroupManager;
|
||||
use OCP\IL10N;
|
||||
use OCP\DB\Exception as DbException;
|
||||
use OCA\Deck\Db\Board;
|
||||
use OCA\Deck\Db\BoardMapper;
|
||||
use OCA\Deck\Db\LabelMapper;
|
||||
use OCP\IUserManager;
|
||||
use OCA\Deck\BadRequestException;
|
||||
use OCP\IURLGenerator;
|
||||
use OCP\Server;
|
||||
|
||||
class BoardService {
|
||||
private $boardMapper;
|
||||
private $stackMapper;
|
||||
private $labelMapper;
|
||||
private $aclMapper;
|
||||
/** @var IConfig */
|
||||
private $config;
|
||||
private $l10n;
|
||||
private $permissionService;
|
||||
private $notificationHelper;
|
||||
private $assignedUsersMapper;
|
||||
private $userManager;
|
||||
private $groupManager;
|
||||
private $userId;
|
||||
private $activityManager;
|
||||
private $eventDispatcher;
|
||||
private $changeHelper;
|
||||
private $cardMapper;
|
||||
|
||||
private $boardsCache = null;
|
||||
private $urlGenerator;
|
||||
|
||||
private BoardMapper $boardMapper;
|
||||
private StackMapper $stackMapper;
|
||||
private LabelMapper $labelMapper;
|
||||
private AclMapper $aclMapper;
|
||||
private IConfig $config;
|
||||
private IL10N $l10n;
|
||||
private PermissionService $permissionService;
|
||||
private NotificationHelper $notificationHelper;
|
||||
private AssignmentMapper $assignedUsersMapper;
|
||||
private IUserManager $userManager;
|
||||
private IGroupManager $groupManager;
|
||||
private ?string $userId;
|
||||
private ActivityManager $activityManager;
|
||||
private IEventDispatcher $eventDispatcher;
|
||||
private ChangeHelper $changeHelper;
|
||||
private CardMapper $cardMapper;
|
||||
private ?array $boardsCache = null;
|
||||
private IURLGenerator $urlGenerator;
|
||||
private IDBConnection $connection;
|
||||
|
||||
public function __construct(
|
||||
BoardMapper $boardMapper,
|
||||
@@ -94,7 +94,8 @@ class BoardService {
|
||||
IEventDispatcher $eventDispatcher,
|
||||
ChangeHelper $changeHelper,
|
||||
IURLGenerator $urlGenerator,
|
||||
$userId
|
||||
IDBConnection $connection,
|
||||
?string $userId
|
||||
) {
|
||||
$this->boardMapper = $boardMapper;
|
||||
$this->stackMapper = $stackMapper;
|
||||
@@ -113,6 +114,7 @@ class BoardService {
|
||||
$this->userId = $userId;
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
$this->cardMapper = $cardMapper;
|
||||
$this->connection = $connection;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -534,7 +536,7 @@ class BoardService {
|
||||
|
||||
// TODO: use the dispatched event for this
|
||||
try {
|
||||
$resourceProvider = \OC::$server->query(\OCA\Deck\Collaboration\Resources\ResourceProvider::class);
|
||||
$resourceProvider = Server::get(\OCA\Deck\Collaboration\Resources\ResourceProvider::class);
|
||||
$resourceProvider->invalidateAccessCache($boardId);
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
@@ -590,18 +592,12 @@ class BoardService {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @return \OCP\AppFramework\Db\Entity
|
||||
* @throws DoesNotExistException
|
||||
* @throws \OCA\Deck\NoPermissionException
|
||||
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||
* @throws BadRequestException
|
||||
*/
|
||||
public function deleteAcl($id) {
|
||||
if (is_numeric($id) === false) {
|
||||
throw new BadRequestException('id must be a number');
|
||||
}
|
||||
|
||||
public function deleteAcl(int $id): bool {
|
||||
$this->permissionService->checkPermission($this->aclMapper, $id, Acl::PERMISSION_SHARE);
|
||||
/** @var Acl $acl */
|
||||
$acl = $this->aclMapper->find($id);
|
||||
@@ -620,7 +616,7 @@ class BoardService {
|
||||
$version = \OCP\Util::getVersion()[0];
|
||||
if ($version >= 16) {
|
||||
try {
|
||||
$resourceProvider = \OC::$server->query(\OCA\Deck\Collaboration\Resources\ResourceProvider::class);
|
||||
$resourceProvider = Server::get(\OCA\Deck\Collaboration\Resources\ResourceProvider::class);
|
||||
$resourceProvider->invalidateAccessCache($acl->getBoardId());
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
@@ -681,7 +677,7 @@ class BoardService {
|
||||
}
|
||||
|
||||
public function transferBoardOwnership(int $boardId, string $newOwner, bool $changeContent = false): Board {
|
||||
\OC::$server->getDatabaseConnection()->beginTransaction();
|
||||
$this->connection->beginTransaction();
|
||||
try {
|
||||
$board = $this->boardMapper->find($boardId);
|
||||
$previousOwner = $board->getOwner();
|
||||
@@ -690,7 +686,10 @@ class BoardService {
|
||||
if (!$changeContent) {
|
||||
try {
|
||||
$this->addAcl($boardId, Acl::PERMISSION_TYPE_USER, $previousOwner, true, true, true);
|
||||
} catch (UniqueConstraintViolationException $e) {
|
||||
} catch (DbException $e) {
|
||||
if ($e->getReason() !== DbException::REASON_UNIQUE_CONSTRAINT_VIOLATION) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->boardMapper->transferOwnership($previousOwner, $newOwner, $boardId);
|
||||
@@ -700,10 +699,10 @@ class BoardService {
|
||||
$this->assignedUsersMapper->remapAssignedUser($boardId, $previousOwner, $newOwner);
|
||||
$this->cardMapper->remapCardOwner($boardId, $previousOwner, $newOwner);
|
||||
}
|
||||
\OC::$server->getDatabaseConnection()->commit();
|
||||
$this->connection->commit();
|
||||
return $this->boardMapper->find($boardId);
|
||||
} catch (\Throwable $e) {
|
||||
\OC::$server->getDatabaseConnection()->rollBack();
|
||||
$this->connection->rollBack();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,26 +45,30 @@ use OCA\Deck\StatusException;
|
||||
use OCA\Deck\BadRequestException;
|
||||
use OCP\Comments\ICommentsManager;
|
||||
use OCP\EventDispatcher\IEventDispatcher;
|
||||
use OCP\IRequest;
|
||||
use OCP\IUserManager;
|
||||
use OCP\IURLGenerator;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class CardService {
|
||||
private $cardMapper;
|
||||
private $stackMapper;
|
||||
private $boardMapper;
|
||||
private $labelMapper;
|
||||
private $permissionService;
|
||||
private $boardService;
|
||||
private $notificationHelper;
|
||||
private $assignedUsersMapper;
|
||||
private $attachmentService;
|
||||
private $currentUser;
|
||||
private $activityManager;
|
||||
private $commentsManager;
|
||||
private $changeHelper;
|
||||
private $eventDispatcher;
|
||||
private $userManager;
|
||||
private $urlGenerator;
|
||||
private CardMapper $cardMapper;
|
||||
private StackMapper $stackMapper;
|
||||
private BoardMapper $boardMapper;
|
||||
private LabelMapper $labelMapper;
|
||||
private PermissionService $permissionService;
|
||||
private BoardService $boardService;
|
||||
private NotificationHelper $notificationHelper;
|
||||
private AssignmentMapper $assignedUsersMapper;
|
||||
private AttachmentService $attachmentService;
|
||||
private ?string $currentUser;
|
||||
private ActivityManager $activityManager;
|
||||
private ICommentsManager $commentsManager;
|
||||
private ChangeHelper $changeHelper;
|
||||
private IEventDispatcher $eventDispatcher;
|
||||
private IUserManager $userManager;
|
||||
private IURLGenerator $urlGenerator;
|
||||
private LoggerInterface $logger;
|
||||
private IRequest $request;
|
||||
|
||||
public function __construct(
|
||||
CardMapper $cardMapper,
|
||||
@@ -82,7 +86,9 @@ class CardService {
|
||||
ChangeHelper $changeHelper,
|
||||
IEventDispatcher $eventDispatcher,
|
||||
IURLGenerator $urlGenerator,
|
||||
$userId
|
||||
LoggerInterface $logger,
|
||||
IRequest $request,
|
||||
?string $userId
|
||||
) {
|
||||
$this->cardMapper = $cardMapper;
|
||||
$this->stackMapper = $stackMapper;
|
||||
@@ -100,6 +106,8 @@ class CardService {
|
||||
$this->eventDispatcher = $eventDispatcher;
|
||||
$this->currentUser = $userId;
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
$this->logger = $logger;
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
public function enrich($card) {
|
||||
@@ -131,23 +139,18 @@ class CardService {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $cardId
|
||||
* @return \OCA\Deck\Db\RelationalEntity
|
||||
* @throws \OCA\Deck\NoPermissionException
|
||||
* @throws \OCP\AppFramework\Db\DoesNotExistException
|
||||
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||
* @throws BadRequestException
|
||||
*/
|
||||
public function find($cardId) {
|
||||
if (is_numeric($cardId) === false) {
|
||||
throw new BadRequestException('card id must be a number');
|
||||
}
|
||||
|
||||
public function find(int $cardId) {
|
||||
$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_READ);
|
||||
$card = $this->cardMapper->find($cardId);
|
||||
$assignedUsers = $this->assignedUsersMapper->findAll($card->getId());
|
||||
$attachments = $this->attachmentService->findAll($cardId, true);
|
||||
if (\OC::$server->getRequest()->getParam('apiVersion') === '1.0') {
|
||||
if ($this->request->getParam('apiVersion') === '1.0') {
|
||||
$attachments = array_filter($attachments, function ($attachment) {
|
||||
return $attachment->getType() === 'deck_file';
|
||||
});
|
||||
@@ -162,7 +165,7 @@ class CardService {
|
||||
try {
|
||||
$this->permissionService->checkPermission($this->boardMapper, $boardId, Acl::PERMISSION_READ);
|
||||
} catch (NoPermissionException $e) {
|
||||
\OC::$server->getLogger()->error('Unable to check permission for a previously obtained board ' . $boardId, ['exception' => $e]);
|
||||
$this->logger->error('Unable to check permission for a previously obtained board ' . $boardId, ['exception' => $e]);
|
||||
return [];
|
||||
}
|
||||
$cards = $this->cardMapper->findCalendarEntries($boardId);
|
||||
@@ -486,7 +489,7 @@ class CardService {
|
||||
* @throws StatusException
|
||||
* @throws \OCA\Deck\NoPermissionException
|
||||
* @throws \OCP\AppFramework\Db\DoesNotExistException
|
||||
* @throws \OCP\AppFramework\Db\
|
||||
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||
* @throws BadRequestException
|
||||
*/
|
||||
public function archive($id) {
|
||||
|
||||
@@ -31,6 +31,7 @@ use OCA\Circles\Model\Circle;
|
||||
use OCA\Circles\Model\Member;
|
||||
use OCA\Circles\Model\Probes\CircleProbe;
|
||||
use OCP\App\IAppManager;
|
||||
use OCP\Server;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
@@ -38,7 +39,7 @@ use Throwable;
|
||||
* having the app disabled is properly handled
|
||||
*/
|
||||
class CirclesService {
|
||||
private $circlesEnabled;
|
||||
private bool $circlesEnabled;
|
||||
|
||||
public function __construct(IAppManager $appManager) {
|
||||
$this->circlesEnabled = $appManager->isEnabledForUser('circles');
|
||||
@@ -56,8 +57,7 @@ class CirclesService {
|
||||
try {
|
||||
|
||||
// Enforce current user condition since we always want the full list of members
|
||||
/** @var CirclesManager $circlesManager */
|
||||
$circlesManager = \OC::$server->get(CirclesManager::class);
|
||||
$circlesManager = Server::get(CirclesManager::class);
|
||||
$circlesManager->startSuperSession();
|
||||
return $circlesManager->getCircle($circleId);
|
||||
} catch (Throwable $e) {
|
||||
@@ -71,8 +71,7 @@ class CirclesService {
|
||||
}
|
||||
|
||||
try {
|
||||
/** @var CirclesManager $circlesManager */
|
||||
$circlesManager = \OC::$server->get(CirclesManager::class);
|
||||
$circlesManager = Server::get(CirclesManager::class);
|
||||
$federatedUser = $circlesManager->getFederatedUser($userId, Member::TYPE_USER);
|
||||
$circlesManager->startSession($federatedUser);
|
||||
$circle = $circlesManager->getCircle($circleId);
|
||||
@@ -93,8 +92,7 @@ class CirclesService {
|
||||
}
|
||||
|
||||
try {
|
||||
/** @var CirclesManager $circlesManager */
|
||||
$circlesManager = \OC::$server->get(CirclesManager::class);
|
||||
$circlesManager = Server::get(CirclesManager::class);
|
||||
$federatedUser = $circlesManager->getFederatedUser($userId, Member::TYPE_USER);
|
||||
$circlesManager->startSession($federatedUser);
|
||||
$probe = new CircleProbe();
|
||||
|
||||
@@ -40,20 +40,14 @@ use OutOfBoundsException;
|
||||
use function is_numeric;
|
||||
|
||||
class CommentService {
|
||||
private ICommentsManager $commentsManager;
|
||||
private IUserManager $userManager;
|
||||
private CardMapper $cardMapper;
|
||||
private PermissionService $permissionService;
|
||||
private ILogger $logger;
|
||||
private ?string $userId;
|
||||
|
||||
/**
|
||||
* @var ICommentsManager
|
||||
*/
|
||||
private $commentsManager;
|
||||
/**
|
||||
* @var IUserManager
|
||||
*/
|
||||
private $userManager;
|
||||
/** @var ILogger */
|
||||
private $logger;
|
||||
private $userId;
|
||||
|
||||
public function __construct(ICommentsManager $commentsManager, PermissionService $permissionService, CardMapper $cardMapper, IUserManager $userManager, ILogger $logger, $userId) {
|
||||
public function __construct(ICommentsManager $commentsManager, PermissionService $permissionService, CardMapper $cardMapper, IUserManager $userManager, ILogger $logger, ?string $userId) {
|
||||
$this->commentsManager = $commentsManager;
|
||||
$this->permissionService = $permissionService;
|
||||
$this->cardMapper = $cardMapper;
|
||||
|
||||
@@ -32,7 +32,6 @@ use OCA\Deck\NoPermissionException;
|
||||
use OCP\IConfig;
|
||||
use OCP\IGroup;
|
||||
use OCP\IGroupManager;
|
||||
use OCP\IUserSession;
|
||||
|
||||
class ConfigService {
|
||||
public const SETTING_BOARD_NOTIFICATION_DUE_OFF = 'off';
|
||||
@@ -40,23 +39,21 @@ class ConfigService {
|
||||
public const SETTING_BOARD_NOTIFICATION_DUE_ALL = 'all';
|
||||
public const SETTING_BOARD_NOTIFICATION_DUE_DEFAULT = self::SETTING_BOARD_NOTIFICATION_DUE_ASSIGNED;
|
||||
|
||||
private $config;
|
||||
private $userId;
|
||||
private $groupManager;
|
||||
private IConfig $config;
|
||||
private ?string $userId;
|
||||
private IGroupManager $groupManager;
|
||||
|
||||
public function __construct(
|
||||
IConfig $config,
|
||||
IGroupManager $groupManager
|
||||
IGroupManager $groupManager,
|
||||
?string $userId
|
||||
) {
|
||||
$this->groupManager = $groupManager;
|
||||
$this->config = $config;
|
||||
$this->userId = $userId;
|
||||
}
|
||||
|
||||
public function getUserId() {
|
||||
if (!$this->userId) {
|
||||
$user = \OC::$server->get(IUserSession::class)->getUser();
|
||||
$this->userId = $user ? $user->getUID() : null;
|
||||
}
|
||||
public function getUserId(): ?string {
|
||||
return $this->userId;
|
||||
}
|
||||
|
||||
@@ -75,8 +72,11 @@ class ConfigService {
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function get($key) {
|
||||
$result = null;
|
||||
/**
|
||||
* @return bool|array{id: string, displayname: string}[]
|
||||
* @throws NoPermissionException
|
||||
*/
|
||||
public function get(string $key) {
|
||||
[$scope] = explode(':', $key, 2);
|
||||
switch ($scope) {
|
||||
case 'groupLimit':
|
||||
@@ -90,11 +90,12 @@ class ConfigService {
|
||||
}
|
||||
return (bool)$this->config->getUserValue($this->getUserId(), Application::APP_ID, 'calendar', true);
|
||||
case 'cardDetailsInModal':
|
||||
if ($this->getUserId() === null) {
|
||||
return false;
|
||||
}
|
||||
if ($this->getUserId() === null) {
|
||||
return false;
|
||||
}
|
||||
return (bool)$this->config->getUserValue($this->getUserId(), Application::APP_ID, 'cardDetailsInModal', true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function isCalendarEnabled(int $boardId = null): bool {
|
||||
@@ -157,7 +158,10 @@ class ConfigService {
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function setGroupLimit($value) {
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
private function setGroupLimit(array $value): array {
|
||||
$groups = [];
|
||||
foreach ($value as $group) {
|
||||
$groups[] = $group['id'];
|
||||
@@ -167,7 +171,7 @@ class ConfigService {
|
||||
return $groups;
|
||||
}
|
||||
|
||||
private function getGroupLimitList() {
|
||||
private function getGroupLimitList(): array {
|
||||
$value = $this->config->getAppValue(Application::APP_ID, 'groupLimit', '');
|
||||
$groups = explode(',', $value);
|
||||
if ($value === '') {
|
||||
@@ -176,9 +180,10 @@ class ConfigService {
|
||||
return $groups;
|
||||
}
|
||||
|
||||
/** @return array{id: string, displayname: string}[] */
|
||||
private function getGroupLimit() {
|
||||
$groups = $this->getGroupLimitList();
|
||||
$groups = array_map(function ($groupId) {
|
||||
$groups = array_map(function (string $groupId): ?array {
|
||||
/** @var IGroup $groups */
|
||||
$group = $this->groupManager->get($groupId);
|
||||
if ($group === null) {
|
||||
|
||||
@@ -88,18 +88,6 @@ class DefaultBoardService {
|
||||
* @throws BadRequestException
|
||||
*/
|
||||
public function createDefaultBoard(string $title, string $userId, string $color) {
|
||||
if ($title === false || $title === null) {
|
||||
throw new BadRequestException('title must be provided');
|
||||
}
|
||||
|
||||
if ($userId === false || $userId === null) {
|
||||
throw new BadRequestException('userId must be provided');
|
||||
}
|
||||
|
||||
if ($color === false || $color === null) {
|
||||
throw new BadRequestException('color must be provided');
|
||||
}
|
||||
|
||||
$defaultBoard = $this->boardService->create($title, $userId, $color);
|
||||
$defaultStacks = [];
|
||||
$defaultCards = [];
|
||||
|
||||
@@ -219,8 +219,11 @@ class FileService implements IAttachmentService {
|
||||
throw new \Exception('no instance id!');
|
||||
}
|
||||
$name = 'appdata_' . $instanceId;
|
||||
/** @var \OCP\Files\Folder $appDataFolder */
|
||||
$appDataFolder = $this->rootFolder->get($name);
|
||||
/** @var \OCP\Files\Folder $appDataFolder */
|
||||
$appDataFolder = $appDataFolder->get('deck');
|
||||
/** @var \OCP\Files\Folder $cardFolder */
|
||||
$cardFolder = $appDataFolder->get($folderName);
|
||||
return $cardFolder->get($attachment->getData());
|
||||
}
|
||||
|
||||
@@ -44,18 +44,19 @@ use OCP\Share\IShare;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class FilesAppService implements IAttachmentService, ICustomAttachmentService {
|
||||
private $request;
|
||||
private $rootFolder;
|
||||
private $shareProvider;
|
||||
private $shareManager;
|
||||
private $userId;
|
||||
private $configService;
|
||||
private $l10n;
|
||||
private $preview;
|
||||
private $mimeTypeDetector;
|
||||
private $permissionService;
|
||||
private $cardMapper;
|
||||
private $logger;
|
||||
private IRequest $request;
|
||||
private IRootFolder $rootFolder;
|
||||
private DeckShareProvider $shareProvider;
|
||||
private IManager $shareManager;
|
||||
private ?string $userId;
|
||||
private ConfigService $configService;
|
||||
private IL10N $l10n;
|
||||
private IPreview $preview;
|
||||
private IMimeTypeDetector $mimeTypeDetector;
|
||||
private PermissionService $permissionService;
|
||||
private CardMapper $cardMapper;
|
||||
private LoggerInterface $logger;
|
||||
private IDBConnection $connection;
|
||||
|
||||
public function __construct(
|
||||
IRequest $request,
|
||||
@@ -69,7 +70,8 @@ class FilesAppService implements IAttachmentService, ICustomAttachmentService {
|
||||
PermissionService $permissionService,
|
||||
CardMapper $cardMapper,
|
||||
LoggerInterface $logger,
|
||||
string $userId = null
|
||||
IDBConnection $connection,
|
||||
?string $userId
|
||||
) {
|
||||
$this->request = $request;
|
||||
$this->l10n = $l10n;
|
||||
@@ -83,6 +85,7 @@ class FilesAppService implements IAttachmentService, ICustomAttachmentService {
|
||||
$this->permissionService = $permissionService;
|
||||
$this->cardMapper = $cardMapper;
|
||||
$this->logger = $logger;
|
||||
$this->connection = $connection;
|
||||
}
|
||||
|
||||
public function listAttachments(int $cardId): array {
|
||||
@@ -108,9 +111,7 @@ class FilesAppService implements IAttachmentService, ICustomAttachmentService {
|
||||
}
|
||||
|
||||
public function getAttachmentCount(int $cardId): int {
|
||||
/** @var IDBConnection $qb */
|
||||
$db = \OC::$server->getDatabaseConnection();
|
||||
$qb = $db->getQueryBuilder();
|
||||
$qb = $this->connection->getQueryBuilder();
|
||||
$qb->select('s.id', 'f.fileid', 'f.path')
|
||||
->selectAlias('st.id', 'storage_string_id')
|
||||
->from('share', 's')
|
||||
@@ -125,7 +126,7 @@ class FilesAppService implements IAttachmentService, ICustomAttachmentService {
|
||||
));
|
||||
|
||||
$count = 0;
|
||||
$cursor = $qb->execute();
|
||||
$cursor = $qb->executeQuery();
|
||||
while ($data = $cursor->fetch()) {
|
||||
if ($this->shareProvider->isAccessibleResult($data)) {
|
||||
$count++;
|
||||
|
||||
@@ -47,34 +47,22 @@ use OCP\Comments\ICommentsManager;
|
||||
use OCP\Comments\NotFoundException as CommentNotFoundException;
|
||||
use OCP\EventDispatcher\IEventDispatcher;
|
||||
use OCP\IUserManager;
|
||||
use OCP\Server;
|
||||
|
||||
class BoardImportService {
|
||||
/** @var IUserManager */
|
||||
private $userManager;
|
||||
/** @var BoardMapper */
|
||||
private $boardMapper;
|
||||
/** @var AclMapper */
|
||||
private $aclMapper;
|
||||
/** @var LabelMapper */
|
||||
private $labelMapper;
|
||||
/** @var StackMapper */
|
||||
private $stackMapper;
|
||||
/** @var CardMapper */
|
||||
private $cardMapper;
|
||||
/** @var AssignmentMapper */
|
||||
private $assignmentMapper;
|
||||
/** @var AttachmentMapper */
|
||||
private $attachmentMapper;
|
||||
/** @var ICommentsManager */
|
||||
private $commentsManager;
|
||||
/** @var IEventDispatcher */
|
||||
private $eventDispatcher;
|
||||
/** @var string */
|
||||
private $system = '';
|
||||
/** @var null|ABoardImportService */
|
||||
private $systemInstance;
|
||||
/** @var array */
|
||||
private $allowedSystems = [];
|
||||
private IUserManager $userManager;
|
||||
private BoardMapper $boardMapper;
|
||||
private AclMapper $aclMapper;
|
||||
private LabelMapper $labelMapper;
|
||||
private StackMapper $stackMapper;
|
||||
private CardMapper $cardMapper;
|
||||
private AssignmentMapper $assignmentMapper;
|
||||
private AttachmentMapper $attachmentMapper;
|
||||
private ICommentsManager $commentsManager;
|
||||
private IEventDispatcher $eventDispatcher;
|
||||
private string $system = '';
|
||||
private ?ABoardImportService $systemInstance;
|
||||
private array $allowedSystems = [];
|
||||
/**
|
||||
* Data object created from config JSON
|
||||
*
|
||||
@@ -89,10 +77,7 @@ class BoardImportService {
|
||||
* @psalm-suppress PropertyNotSetInConstructor
|
||||
*/
|
||||
private $data;
|
||||
/**
|
||||
* @var Board
|
||||
*/
|
||||
private $board;
|
||||
private Board $board;
|
||||
|
||||
public function __construct(
|
||||
IUserManager $userManager,
|
||||
@@ -198,7 +183,7 @@ class BoardImportService {
|
||||
}
|
||||
if (!is_object($this->systemInstance)) {
|
||||
$systemClass = 'OCA\\Deck\\Service\\Importer\\Systems\\' . ucfirst($this->getSystem()) . 'Service';
|
||||
$this->systemInstance = \OC::$server->get($systemClass);
|
||||
$this->systemInstance = Server::get($systemClass);
|
||||
$this->systemInstance->setImportService($this);
|
||||
}
|
||||
return $this->systemInstance;
|
||||
@@ -343,7 +328,7 @@ class BoardImportService {
|
||||
}
|
||||
|
||||
public function insertAttachment(Attachment $attachment, string $content): Attachment {
|
||||
$service = \OC::$server->get(FileService::class);
|
||||
$service = Server::get(FileService::class);
|
||||
$folder = $service->getFolder($attachment);
|
||||
|
||||
if ($folder->fileExists($attachment->getData())) {
|
||||
|
||||
@@ -39,19 +39,21 @@ use OCA\Deck\Db\StackMapper;
|
||||
use OCA\Deck\Model\CardDetails;
|
||||
use OCA\Deck\NoPermissionException;
|
||||
use OCA\Deck\StatusException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class StackService {
|
||||
private $stackMapper;
|
||||
private $cardMapper;
|
||||
private $boardMapper;
|
||||
private $labelMapper;
|
||||
private $permissionService;
|
||||
private $boardService;
|
||||
private $cardService;
|
||||
private $assignedUsersMapper;
|
||||
private $attachmentService;
|
||||
private $activityManager;
|
||||
private $changeHelper;
|
||||
private StackMapper $stackMapper;
|
||||
private CardMapper $cardMapper;
|
||||
private BoardMapper $boardMapper;
|
||||
private LabelMapper $labelMapper;
|
||||
private PermissionService $permissionService;
|
||||
private BoardService $boardService;
|
||||
private CardService $cardService;
|
||||
private AssignmentMapper $assignedUsersMapper;
|
||||
private AttachmentService $attachmentService;
|
||||
private ActivityManager $activityManager;
|
||||
private ChangeHelper $changeHelper;
|
||||
private LoggerInterface $logger;
|
||||
|
||||
public function __construct(
|
||||
StackMapper $stackMapper,
|
||||
@@ -64,7 +66,8 @@ class StackService {
|
||||
AssignmentMapper $assignedUsersMapper,
|
||||
AttachmentService $attachmentService,
|
||||
ActivityManager $activityManager,
|
||||
ChangeHelper $changeHelper
|
||||
ChangeHelper $changeHelper,
|
||||
LoggerInterface $logger
|
||||
) {
|
||||
$this->stackMapper = $stackMapper;
|
||||
$this->boardMapper = $boardMapper;
|
||||
@@ -77,6 +80,7 @@ class StackService {
|
||||
$this->attachmentService = $attachmentService;
|
||||
$this->activityManager = $activityManager;
|
||||
$this->changeHelper = $changeHelper;
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
private function enrichStackWithCards($stack, $since = -1) {
|
||||
@@ -158,7 +162,7 @@ class StackService {
|
||||
try {
|
||||
$this->permissionService->checkPermission(null, $boardId, Acl::PERMISSION_READ);
|
||||
} catch (NoPermissionException $e) {
|
||||
\OC::$server->getLogger()->error('Unable to check permission for a previously obtained board ' . $boardId, ['exception' => $e]);
|
||||
$this->logger->error('Unable to check permission for a previously obtained board ' . $boardId, ['exception' => $e]);
|
||||
return [];
|
||||
}
|
||||
return $this->stackMapper->findAll($boardId);
|
||||
|
||||
Reference in New Issue
Block a user