corrected null errors from first attempt.

Signed-off-by: Ryan Fletcher <ryan.fletcher@codepassion.ca>
This commit is contained in:
Ryan Fletcher
2018-07-10 19:29:55 -04:00
parent e208fd8222
commit 683354da9d
2 changed files with 16 additions and 10 deletions

View File

@@ -30,18 +30,19 @@ use OCP\AppFramework\Controller;
class PageController extends Controller { class PageController extends Controller {
protected $defaultBoardService; private $defaultBoardService;
private $userId; private $userId;
public function __construct( public function __construct(
$AppName, $AppName,
IRequest $request, IRequest $request,
$userId, DefaultBoardService $defaultBoardService,
DefaultBoardService $defaultBoardService) { $userId
) {
parent::__construct($AppName, $request); parent::__construct($AppName, $request);
$this->userId = $userId; $this->userId = $userId;
$this->boardService = $boardService; $this->defaultBoardService = $defaultBoardService;
} }
/** /**
@@ -60,7 +61,7 @@ class PageController extends Controller {
// run the checkFirstRun() method from OCA\Deck\Service\DefaultBoardService here // run the checkFirstRun() method from OCA\Deck\Service\DefaultBoardService here
// if the board is not created, then run createDefaultBoard() from the defaultBoardService here. // if the board is not created, then run createDefaultBoard() from the defaultBoardService here.
if ($this->defaultBoardService->checkFirstRun($this->userId)) { if ($this->defaultBoardService->checkFirstRun($this->userId)) {
$this->defaultBoardService->createDefaultBoard(); $this->defaultBoardService->createDefaultBoard('Personal', $this->userId, '000000');
} }

View File

@@ -33,9 +33,14 @@ class DefaultBoardService {
protected $stackService; protected $stackService;
protected $cardService; protected $cardService;
public function __construct(BoardService $boardService, StackService $stackService, CardService $cardService) { public function __construct(
BoardService $boardService,
StackService $stackService,
CardService $cardService) {
$this->boardService = $boardService; $this->boardService = $boardService;
$this->stackService = $stackService; $this->stackService = $stackService;
$this->cardService = $cardService;
} }
@@ -44,7 +49,7 @@ class DefaultBoardService {
// has already been created for the user // has already been created for the user
// TODO: Remove hardcode once I figure out how to do the config value. // TODO: Remove hardcode once I figure out how to do the config value.
return true; return false;
} }
public function createDefaultBoard($title, $userId, $color) { public function createDefaultBoard($title, $userId, $color) {
@@ -58,8 +63,8 @@ class DefaultBoardService {
$defaultStacks[] = $this->stackService->create('Doing', $boardId, 1); $defaultStacks[] = $this->stackService->create('Doing', $boardId, 1);
$defaultStacks[] = $this->stackService->create('Done', $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 3', $defaultStacks[0]->getId(), 'text', 0, $userId);
$defaultCards[] = $this->cardService->create('Example Task 2', $stacks[1]->getId(), 'text', 0, $userId); $defaultCards[] = $this->cardService->create('Example Task 2', $defaultStacks[1]->getId(), 'text', 0, $userId);
$defaultCards[] = $this->cardService->create('Example Task 1', $stacks[2]->getId(), 'text', 0, $userId); $defaultCards[] = $this->cardService->create('Example Task 1', $defaultStacks[2]->getId(), 'text', 0, $userId);
} }
} }