Skip to content

Commit

Permalink
Fixes to SetupCommand (CFM-28)
Browse files Browse the repository at this point in the history
  • Loading branch information
Benn Oshrin committed Oct 1, 2022
1 parent 9691be0 commit 878edac
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
16 changes: 13 additions & 3 deletions app/src/Command/SetupCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,9 @@ public function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionPar
/**
* Execute the Setup Command.
*
* @param Arguments $args Command Arguments
* @param ConsoleIo $io Console IO
*
* @since COmanage Registry v5.0.0
* @param Arguments $args Command Arguments
* @param ConsoleIo $io Console IO
*/

public function execute(Arguments $args, ConsoleIo $io)
Expand Down Expand Up @@ -107,8 +106,19 @@ public function execute(Arguments $args, ConsoleIo $io)
$username = $io->ask(__d('command', 'opt.admin-username'));
}

// Setup the COmanage CO
$coTable = $this->getTableLocator()->get('Cos');

$io->out(__d('command', 'se.db.co'));

$co_id = $coTable->setupCOmanageCO();

if(is_null($co_id)) {
throw new \RuntimeException('setup.co.comanage');
}

$io->out(__d('command', 'se.db.co.done', [$co_id]));

// Add the first CMP Administrator

$io->out(__d('command', 'se.db.cmpadmin'));
Expand Down
9 changes: 6 additions & 3 deletions app/src/Lib/Traits/PrimaryLinkTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,14 @@ public function lookupPersonId($entity): ?int {
return $linkEntity->person_id;
} else {
// Our parent link does not directly point to Person, so try recursing
// on our parent table
// on our parent table, though we might also not have a parent that points
// to a Person (eg Group -> Co).

$LinkTable = TableRegistry::getTableLocator()->get($linkEntity->getSource());

return $LinkTable->lookupPersonId($linkEntity);

if(method_exists($LinkTable, "lookupPersonId")) {
return $LinkTable->lookupPersonId($linkEntity);
}
}
}

Expand Down

0 comments on commit 878edac

Please sign in to comment.