first attempt at writing the checkFirstRun() in DefaultBoardService.php

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

View File

@@ -58,13 +58,10 @@ class PageController extends Controller {
'maxUploadSize' => \OCP\Util::uploadLimit(), 'maxUploadSize' => \OCP\Util::uploadLimit(),
]; ];
// run the checkFirstRun() method from OCA\Deck\Service\DefaultBoardService here if ($this->defaultBoardService->checkFirstRun($this->userId, $AppName)) {
// if the board is not created, then run createDefaultBoard() from the defaultBoardService here.
if ($this->defaultBoardService->checkFirstRun($this->userId)) {
$this->defaultBoardService->createDefaultBoard('Personal', $this->userId, '000000'); $this->defaultBoardService->createDefaultBoard('Personal', $this->userId, '000000');
} }
return new TemplateResponse('deck', 'main', $params); return new TemplateResponse('deck', 'main', $params);
} }

View File

@@ -26,29 +26,36 @@ namespace OCA\Deck\Service;
use OCA\Deck\Service\BoardService; use OCA\Deck\Service\BoardService;
use OCA\Deck\Service\StackService; use OCA\Deck\Service\StackService;
use OCA\Deck\Service\CardService; use OCA\Deck\Service\CardService;
use OCP\IConfig;
class DefaultBoardService { class DefaultBoardService {
protected $boardService; private $boardService;
protected $stackService; private $stackService;
protected $cardService; private $cardService;
private $config;
public function __construct( public function __construct(
BoardService $boardService, BoardService $boardService,
StackService $stackService, StackService $stackService,
CardService $cardService) { CardService $cardService,
IConfig $config
) {
$this->boardService = $boardService; $this->boardService = $boardService;
$this->stackService = $stackService; $this->stackService = $stackService;
$this->cardService = $cardService; $this->cardService = $cardService;
$this->config = $config;
} }
public function checkFirstRun($userId, $appName) {
$firstRun = $this->config->getUserValue($userId,$appName,'firstRun','yes');
public function checkFirstRun($userId) { if ($firstRun == 'yes') {
// Add a user config value like 'firstrun' to check if the default board $this->config->setUserValue($userId,$appName,'firstRun','no');
// has already been created for the user return true;
}
// TODO: Remove hardcode once I figure out how to do the config value.
return false; return false;
} }