mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-09 16:53:11 +08:00
More classes renamed and fixes for usage of the short code concept in place of short URL
This commit is contained in:
@@ -9,7 +9,7 @@ use Psr\Log\LoggerInterface;
|
||||
use Shlinkio\Shlink\Core\Exception\InvalidArgumentException;
|
||||
use Shlinkio\Shlink\Core\Exception\InvalidUrlException;
|
||||
use Shlinkio\Shlink\Core\Exception\NonUniqueSlugException;
|
||||
use Shlinkio\Shlink\Core\Model\CreateShortCodeData;
|
||||
use Shlinkio\Shlink\Core\Model\CreateShortUrlData;
|
||||
use Shlinkio\Shlink\Core\Service\UrlShortenerInterface;
|
||||
use Shlinkio\Shlink\Core\Transformer\ShortUrlDataTransformer;
|
||||
use Shlinkio\Shlink\Rest\Action\AbstractRestAction;
|
||||
@@ -52,10 +52,10 @@ abstract class AbstractCreateShortUrlAction extends AbstractRestAction
|
||||
public function handle(Request $request): Response
|
||||
{
|
||||
try {
|
||||
$shortCodeData = $this->buildUrlToShortCodeData($request);
|
||||
$shortCodeMeta = $shortCodeData->getMeta();
|
||||
$longUrl = $shortCodeData->getLongUrl();
|
||||
$customSlug = $shortCodeMeta->getCustomSlug();
|
||||
$shortUrlData = $this->buildShortUrlData($request);
|
||||
$shortUrlMeta = $shortUrlData->getMeta();
|
||||
$longUrl = $shortUrlData->getLongUrl();
|
||||
$customSlug = $shortUrlMeta->getCustomSlug();
|
||||
} catch (InvalidArgumentException $e) {
|
||||
$this->logger->warning('Provided data is invalid.' . PHP_EOL . $e);
|
||||
return new JsonResponse([
|
||||
@@ -67,11 +67,11 @@ abstract class AbstractCreateShortUrlAction extends AbstractRestAction
|
||||
try {
|
||||
$shortUrl = $this->urlShortener->urlToShortCode(
|
||||
$longUrl,
|
||||
$shortCodeData->getTags(),
|
||||
$shortCodeMeta->getValidSince(),
|
||||
$shortCodeMeta->getValidUntil(),
|
||||
$shortUrlData->getTags(),
|
||||
$shortUrlMeta->getValidSince(),
|
||||
$shortUrlMeta->getValidUntil(),
|
||||
$customSlug,
|
||||
$shortCodeMeta->getMaxVisits()
|
||||
$shortUrlMeta->getMaxVisits()
|
||||
);
|
||||
$transformer = new ShortUrlDataTransformer($this->domainConfig);
|
||||
|
||||
@@ -95,7 +95,7 @@ abstract class AbstractCreateShortUrlAction extends AbstractRestAction
|
||||
),
|
||||
], self::STATUS_BAD_REQUEST);
|
||||
} catch (\Throwable $e) {
|
||||
$this->logger->error('Unexpected error creating shortcode.' . PHP_EOL . $e);
|
||||
$this->logger->error('Unexpected error creating short url.' . PHP_EOL . $e);
|
||||
return new JsonResponse([
|
||||
'error' => RestUtils::UNKNOWN_ERROR,
|
||||
'message' => $this->translator->translate('Unexpected error occurred'),
|
||||
@@ -105,8 +105,8 @@ abstract class AbstractCreateShortUrlAction extends AbstractRestAction
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return CreateShortCodeData
|
||||
* @return CreateShortUrlData
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
abstract protected function buildUrlToShortCodeData(Request $request): CreateShortCodeData;
|
||||
abstract protected function buildShortUrlData(Request $request): CreateShortUrlData;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user