Fix indentation

This commit is contained in:
Julius Haertl
2017-01-18 12:44:19 +01:00
parent 823dbbd04b
commit 8f6e923e85
4 changed files with 33 additions and 48 deletions

View File

@@ -43,13 +43,7 @@ class BoardService {
private $l10n; private $l10n;
private $permissionService; private $permissionService;
public function __construct( public function __construct(BoardMapper $boardMapper, IL10N $l10n, LabelMapper $labelMapper, AclMapper $aclMapper, PermissionService $permissionService) {
BoardMapper $boardMapper,
IL10N $l10n,
LabelMapper $labelMapper,
AclMapper $aclMapper,
PermissionService $permissionService
) {
$this->boardMapper = $boardMapper; $this->boardMapper = $boardMapper;
$this->labelMapper = $labelMapper; $this->labelMapper = $labelMapper;
$this->aclMapper = $aclMapper; $this->aclMapper = $aclMapper;
@@ -78,10 +72,11 @@ class BoardService {
// create new labels // create new labels
$default_labels = [ $default_labels = [
'31CC7C' => $this->l10n->t('Finished'), '31CC7C' => $this->l10n->t('Finished'),
'317CCC' => $this->l10n->t('To review'), '317CCC' => $this->l10n->t('To review'),
'FF7A66' => $this->l10n->t('Action needed'), 'FF7A66' => $this->l10n->t('Action needed'),
'F1DB50' => $this->l10n->t('Later')]; 'F1DB50' => $this->l10n->t('Later')
];
$labels = []; $labels = [];
foreach ($default_labels as $color => $title) { foreach ($default_labels as $color => $title) {
$label = new Label(); $label = new Label();

View File

@@ -5,20 +5,20 @@
* @author Julius Härtl <jus@bitgrid.net> * @author Julius Härtl <jus@bitgrid.net>
* *
* @license GNU AGPL version 3 or any later version * @license GNU AGPL version 3 or any later version
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the * published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
namespace OCA\Deck\Service; namespace OCA\Deck\Service;
@@ -30,15 +30,11 @@ use OCA\Deck\CardArchivedException;
use OCA\Deck\Db\StackMapper; use OCA\Deck\Db\StackMapper;
class CardService { class CardService {
private $cardMapper; private $cardMapper;
public function __construct( public function __construct(CardMapper $cardMapper, StackMapper $stackMapper, PermissionService $permissionService) {
CardMapper $cardMapper,
StackMapper $stackMapper,
PermissionService $permissionService
) {
$this->cardMapper = $cardMapper; $this->cardMapper = $cardMapper;
$this->stackMapper = $stackMapper; $this->stackMapper = $stackMapper;
$this->permissionService = $permissionService; $this->permissionService = $permissionService;
@@ -48,6 +44,7 @@ class CardService {
$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_READ); $this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_READ);
return $this->cardMapper->find($cardId); return $this->cardMapper->find($cardId);
} }
public function create($title, $stackId, $type, $order, $owner) { public function create($title, $stackId, $type, $order, $owner) {
$this->permissionService->checkPermission($this->stackMapper, $stackId, Acl::PERMISSION_EDIT); $this->permissionService->checkPermission($this->stackMapper, $stackId, Acl::PERMISSION_EDIT);
$card = new Card(); $card = new Card();
@@ -68,7 +65,7 @@ class CardService {
public function update($id, $title, $stackId, $type, $order, $description, $owner) { public function update($id, $title, $stackId, $type, $order, $description, $owner) {
$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT); $this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
$card = $this->cardMapper->find($id); $card = $this->cardMapper->find($id);
if($card->getArchived()) { if ($card->getArchived()) {
throw new CardArchivedException(); throw new CardArchivedException();
} }
$card->setTitle($title); $card->setTitle($title);
@@ -83,30 +80,31 @@ class CardService {
public function rename($id, $title) { public function rename($id, $title) {
$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT); $this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
$card = $this->cardMapper->find($id); $card = $this->cardMapper->find($id);
if($card->getArchived()) { if ($card->getArchived()) {
throw new CardArchivedException(); throw new CardArchivedException();
} }
$card->setTitle($title); $card->setTitle($title);
return $this->cardMapper->update($card); return $this->cardMapper->update($card);
} }
public function reorder($id, $stackId, $order) { public function reorder($id, $stackId, $order) {
$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT); $this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
$cards = $this->cardMapper->findAll($stackId); $cards = $this->cardMapper->findAll($stackId);
$result = []; $result = [];
$i = 0; $i = 0;
foreach ($cards as $card) { foreach ($cards as $card) {
if($card->getArchived()) { if ($card->getArchived()) {
throw new CardArchivedException(); throw new CardArchivedException();
} }
if($card->id === $id) { if ($card->id === $id) {
$card->setOrder($order); $card->setOrder($order);
$card->setLastModified(time()); $card->setLastModified(time());
} }
if($i === $order) if ($i === $order)
$i++; $i++;
if($card->id !== $id) { if ($card->id !== $id) {
$card->setOrder($i++); $card->setOrder($i++);
} }
$this->cardMapper->update($card); $this->cardMapper->update($card);
@@ -122,7 +120,7 @@ class CardService {
$card->setArchived(true); $card->setArchived(true);
return $this->cardMapper->update($card); return $this->cardMapper->update($card);
} }
public function unarchive($id) { public function unarchive($id) {
$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT); $this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
$card = $this->cardMapper->find($id); $card = $this->cardMapper->find($id);
@@ -133,7 +131,7 @@ class CardService {
public function assignLabel($cardId, $labelId) { public function assignLabel($cardId, $labelId) {
$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT); $this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT);
$card = $this->cardMapper->find($cardId); $card = $this->cardMapper->find($cardId);
if($card->getArchived()) { if ($card->getArchived()) {
throw new CardArchivedException(); throw new CardArchivedException();
} }
$this->cardMapper->assignLabel($cardId, $labelId); $this->cardMapper->assignLabel($cardId, $labelId);
@@ -142,7 +140,7 @@ class CardService {
public function removeLabel($cardId, $labelId) { public function removeLabel($cardId, $labelId) {
$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT); $this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT);
$card = $this->cardMapper->find($cardId); $card = $this->cardMapper->find($cardId);
if($card->getArchived()) { if ($card->getArchived()) {
throw new CardArchivedException(); throw new CardArchivedException();
} }
$this->cardMapper->removeLabel($cardId, $labelId); $this->cardMapper->removeLabel($cardId, $labelId);

View File

@@ -32,10 +32,7 @@ class LabelService {
private $labelMapper; private $labelMapper;
public function __construct( public function __construct(LabelMapper $labelMapper, PermissionService $permissionService) {
LabelMapper $labelMapper,
PermissionService $permissionService
) {
$this->labelMapper = $labelMapper; $this->labelMapper = $labelMapper;
$this->permissionService = $permissionService; $this->permissionService = $permissionService;
} }

View File

@@ -43,12 +43,7 @@ class PermissionService {
private $logger; private $logger;
private $userId; private $userId;
public function __construct(ILogger $logger, public function __construct(ILogger $logger, AclMapper $aclMapper, BoardMapper $boardMapper, IGroupManager $groupManager, $userId) {
AclMapper $aclMapper,
BoardMapper $boardMapper,
IGroupManager $groupManager,
$userId
) {
$this->aclMapper = $aclMapper; $this->aclMapper = $aclMapper;
$this->boardMapper = $boardMapper; $this->boardMapper = $boardMapper;
$this->logger = $logger; $this->logger = $logger;
@@ -82,14 +77,14 @@ class PermissionService {
* @return bool * @return bool
* @throws NoPermissionException * @throws NoPermissionException
*/ */
public function checkPermission($mapper, $id, $permission) { public function checkPermission($mapper, $id, $permission) {
try { try {
if($mapper instanceof IPermissionMapper) { if ($mapper instanceof IPermissionMapper) {
$boardId = $mapper->findBoardId($id); $boardId = $mapper->findBoardId($id);
} else { } else {
$boardId = $id; $boardId = $id;
} }
if($boardId === null) { if ($boardId === null) {
// Throw NoPermission to not leak information about existing entries // Throw NoPermission to not leak information about existing entries
throw new NoPermissionException('Permission denied'); throw new NoPermissionException('Permission denied');
} }
@@ -104,8 +99,8 @@ class PermissionService {
} }
} catch (DoesNotExistException $exception) { } catch (DoesNotExistException $exception) {
// Throw NoPermission to not leak information about existing entries // Throw NoPermission to not leak information about existing entries
throw new NoPermissionException('Permission denied'); throw new NoPermissionException('Permission denied');
} }
throw new NoPermissionException('Permission denied.'); throw new NoPermissionException('Permission denied.');