-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from leepeuker/add-trakt-client-id-to-user-set…
…tings-page Add trakt username to settings page
- Loading branch information
Showing
16 changed files
with
172 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/Application/Service/Trakt/Exception/TraktUserNameNotSet.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Movary\Application\Service\Trakt\Exception; | ||
|
||
class TraktUserNameNotSet extends \Exception | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Movary\Command; | ||
|
||
use Movary\Application\User; | ||
use Psr\Log\LoggerInterface; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class ChangeUserTraktUserName extends Command | ||
{ | ||
protected static $defaultName = self::COMMAND_BASE_NAME . ':user:change-trakt-username'; | ||
|
||
public function __construct( | ||
private readonly User\Api $userApi, | ||
private readonly LoggerInterface $logger, | ||
) { | ||
parent::__construct(); | ||
} | ||
|
||
protected function configure() : void | ||
{ | ||
$this | ||
->setDescription('Change user trakt client id.') | ||
->addArgument('userId', InputArgument::REQUIRED, 'ID of user') | ||
->addArgument('traktUserName', InputArgument::REQUIRED, 'New trakt username for user'); | ||
} | ||
|
||
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter | ||
protected function execute(InputInterface $input, OutputInterface $output) : int | ||
{ | ||
$userId = (int)$input->getArgument('userId'); | ||
$traktUserName = $input->getArgument('traktUserName'); | ||
|
||
if (empty($traktUserName) === true) { | ||
$traktUserName = null; | ||
} | ||
|
||
try { | ||
$this->userApi->updateTraktUserName($userId, $traktUserName); | ||
} catch (\Throwable $t) { | ||
$this->logger->error('Could not change trakt username.', ['exception' => $t]); | ||
|
||
$this->generateOutput($output, 'Could not update trakt username.'); | ||
|
||
return Command::FAILURE; | ||
} | ||
|
||
$this->generateOutput($output, 'Updated trakt username.'); | ||
return Command::SUCCESS; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.