Skip to content

Commit

Permalink
corrected null errors from first attempt.
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Fletcher <ryan.fletcher@codepassion.ca>
  • Loading branch information
Ryan Fletcher committed Jul 10, 2018
1 parent e208fd8 commit 683354d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
11 changes: 6 additions & 5 deletions lib/Controller/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,19 @@

class PageController extends Controller {

protected $defaultBoardService;
private $defaultBoardService;
private $userId;

public function __construct(
$AppName,
IRequest $request,
$userId,
DefaultBoardService $defaultBoardService) {
DefaultBoardService $defaultBoardService,
$userId
) {
parent::__construct($AppName, $request);

$this->userId = $userId;
$this->boardService = $boardService;
$this->defaultBoardService = $defaultBoardService;
}

/**
Expand All @@ -60,7 +61,7 @@ public function index() {
// run the checkFirstRun() method from OCA\Deck\Service\DefaultBoardService here
// if the board is not created, then run createDefaultBoard() from the defaultBoardService here.
if ($this->defaultBoardService->checkFirstRun($this->userId)) {
$this->defaultBoardService->createDefaultBoard();
$this->defaultBoardService->createDefaultBoard('Personal', $this->userId, '000000');

This comment was marked as resolved.

Copy link
@juliusknorr

juliusknorr Jul 11, 2018

Member

Please inject \OCP\IL10N in the constructor and make the 'Personal' string translatable with $this->l10n->t();

}


Expand Down
15 changes: 10 additions & 5 deletions lib/Service/DefaultBoardService.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,14 @@ class DefaultBoardService {
protected $stackService;
protected $cardService;

public function __construct(BoardService $boardService, StackService $stackService, CardService $cardService) {
public function __construct(
BoardService $boardService,
StackService $stackService,
CardService $cardService) {

$this->boardService = $boardService;
$this->stackService = $stackService;
$this->cardService = $cardService;
}


Expand All @@ -44,7 +49,7 @@ public function checkFirstRun($userId) {
// has already been created for the user

// TODO: Remove hardcode once I figure out how to do the config value.
return true;
return false;
}

public function createDefaultBoard($title, $userId, $color) {
Expand All @@ -58,8 +63,8 @@ public function createDefaultBoard($title, $userId, $color) {
$defaultStacks[] = $this->stackService->create('Doing', $boardId, 1);
$defaultStacks[] = $this->stackService->create('Done', $boardId, 1);

$defaultCards[] = $this->cardService->create('Example Task 3', $stacks[0]->getId(), 'text', 0, $userId);
$defaultCards[] = $this->cardService->create('Example Task 2', $stacks[1]->getId(), 'text', 0, $userId);
$defaultCards[] = $this->cardService->create('Example Task 1', $stacks[2]->getId(), 'text', 0, $userId);
$defaultCards[] = $this->cardService->create('Example Task 3', $defaultStacks[0]->getId(), 'text', 0, $userId);
$defaultCards[] = $this->cardService->create('Example Task 2', $defaultStacks[1]->getId(), 'text', 0, $userId);
$defaultCards[] = $this->cardService->create('Example Task 1', $defaultStacks[2]->getId(), 'text', 0, $userId);
}
}

0 comments on commit 683354d

Please sign in to comment.