Skip to content

Commit

Permalink
fixup! fixup! fixup! Add a service
Browse files Browse the repository at this point in the history
  • Loading branch information
nickvergessen committed Jan 23, 2019
1 parent 078e9b0 commit 99b4c3c
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions lib/Service/CommandService.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,22 +95,24 @@ public function update(int $id, string $cmd, string $name, string $script, int $
throw new \InvalidArgumentException('enabled', 5);
}

if ($command->getApp() !== '' && $command->getCommand() !== 'help') {
if ($cmd !== $command->getCommand()) {
try {
$this->mapper->find('', $cmd);
throw new \InvalidArgumentException('command', 1);
} catch (DoesNotExistException $e) {
$command->setCommand($cmd);
}
}
if ($command->getApp() !== '' || $command->getCommand() === 'help') {
throw new \InvalidArgumentException('app', 0);
}

// FIXME Validate "bot name"
$command->setName($name);
// FIXME Validate "script"
$command->setScript($script);
if ($cmd !== $command->getCommand()) {
try {
$this->mapper->find('', $cmd);
throw new \InvalidArgumentException('command', 1);
} catch (DoesNotExistException $e) {
$command->setCommand($cmd);
}
}

// FIXME Validate "bot name"
$command->setName($name);
// FIXME Validate "script"
$command->setScript($script);

$command->setResponse($response);
$command->setEnabled($enabled);

Expand Down

0 comments on commit 99b4c3c

Please sign in to comment.