From 57566095310131fd45826439a60e78ad2de45e02 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Tue, 29 Jan 2019 13:20:46 +0100 Subject: [PATCH] Deleted deprecated constant --- module/CLI/src/Command/Config/GenerateCharsetCommand.php | 6 +++--- module/Core/src/Service/UrlShortener.php | 2 -- .../src/Config/Plugin/UrlShortenerConfigCustomizer.php | 4 ++-- .../src/Action/ShortUrl/AbstractCreateShortUrlAction.php | 8 ++++---- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/module/CLI/src/Command/Config/GenerateCharsetCommand.php b/module/CLI/src/Command/Config/GenerateCharsetCommand.php index 5fe417d7..34e23195 100644 --- a/module/CLI/src/Command/Config/GenerateCharsetCommand.php +++ b/module/CLI/src/Command/Config/GenerateCharsetCommand.php @@ -3,7 +3,7 @@ declare(strict_types=1); namespace Shlinkio\Shlink\CLI\Command\Config; -use Shlinkio\Shlink\Core\Service\UrlShortener; +use Shlinkio\Shlink\Core\Options\UrlShortenerOptions; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -22,13 +22,13 @@ class GenerateCharsetCommand extends Command ->setDescription(sprintf( 'Generates a character set sample just by shuffling the default one, "%s". ' . 'Then it can be set in the SHORTCODE_CHARS environment variable', - UrlShortener::DEFAULT_CHARS + UrlShortenerOptions::DEFAULT_CHARS )); } protected function execute(InputInterface $input, OutputInterface $output): void { - $charSet = str_shuffle(UrlShortener::DEFAULT_CHARS); + $charSet = str_shuffle(UrlShortenerOptions::DEFAULT_CHARS); (new SymfonyStyle($input, $output))->success(sprintf('Character set: "%s"', $charSet)); } } diff --git a/module/Core/src/Service/UrlShortener.php b/module/Core/src/Service/UrlShortener.php index c02e8f70..24a7ced4 100644 --- a/module/Core/src/Service/UrlShortener.php +++ b/module/Core/src/Service/UrlShortener.php @@ -29,8 +29,6 @@ class UrlShortener implements UrlShortenerInterface { use TagManagerTrait; - /** @deprecated */ - public const DEFAULT_CHARS = UrlShortenerOptions::DEFAULT_CHARS; private const ID_INCREMENT = 200000; /** @var ClientInterface */ diff --git a/module/Installer/src/Config/Plugin/UrlShortenerConfigCustomizer.php b/module/Installer/src/Config/Plugin/UrlShortenerConfigCustomizer.php index 0e5d4a00..0ef0c8d6 100644 --- a/module/Installer/src/Config/Plugin/UrlShortenerConfigCustomizer.php +++ b/module/Installer/src/Config/Plugin/UrlShortenerConfigCustomizer.php @@ -3,7 +3,7 @@ declare(strict_types=1); namespace Shlinkio\Shlink\Installer\Config\Plugin; -use Shlinkio\Shlink\Core\Service\UrlShortener; +use Shlinkio\Shlink\Core\Options\UrlShortenerOptions; use Shlinkio\Shlink\Installer\Model\CustomizableAppConfig; use Shlinkio\Shlink\Installer\Util\AskUtilsTrait; use Symfony\Component\Console\Style\SymfonyStyle; @@ -66,7 +66,7 @@ class UrlShortenerConfigCustomizer implements ConfigCustomizerInterface case self::CHARS: return $io->ask( 'Character set for generated short codes (leave empty to autogenerate one)' - ) ?: str_shuffle(UrlShortener::DEFAULT_CHARS); + ) ?: str_shuffle(UrlShortenerOptions::DEFAULT_CHARS); case self::VALIDATE_URL: return $io->confirm('Do you want to validate long urls by 200 HTTP status code on response'); case self::ENABLE_NOT_FOUND_REDIRECTION: diff --git a/module/Rest/src/Action/ShortUrl/AbstractCreateShortUrlAction.php b/module/Rest/src/Action/ShortUrl/AbstractCreateShortUrlAction.php index 33849c23..4e90e4e2 100644 --- a/module/Rest/src/Action/ShortUrl/AbstractCreateShortUrlAction.php +++ b/module/Rest/src/Action/ShortUrl/AbstractCreateShortUrlAction.php @@ -38,15 +38,11 @@ abstract class AbstractCreateShortUrlAction extends AbstractRestAction /** * @param Request $request * @return Response - * @throws \InvalidArgumentException */ public function handle(Request $request): Response { try { $shortUrlData = $this->buildShortUrlData($request); - $shortUrlMeta = $shortUrlData->getMeta(); - $longUrl = $shortUrlData->getLongUrl(); - $customSlug = $shortUrlMeta->getCustomSlug(); } catch (InvalidArgumentException $e) { $this->logger->warning('Provided data is invalid. {e}', ['e' => $e]); return new JsonResponse([ @@ -55,6 +51,10 @@ abstract class AbstractCreateShortUrlAction extends AbstractRestAction ], self::STATUS_BAD_REQUEST); } + $longUrl = $shortUrlData->getLongUrl(); + $shortUrlMeta = $shortUrlData->getMeta(); + $customSlug = $shortUrlMeta->getCustomSlug(); + try { $shortUrl = $this->urlShortener->urlToShortCode( $longUrl,