mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-07 07:43:12 +08:00
Added valid_since and valid_until columns to shoirt_urls table
This commit is contained in:
@@ -49,7 +49,7 @@ return [
|
||||
Service\Tag\TagService::class => ['em'],
|
||||
|
||||
// Middleware
|
||||
Action\RedirectAction::class => [Service\UrlShortener::class, Service\VisitsTracker::class, 'Logger_Shlink'],
|
||||
Action\RedirectAction::class => [Service\UrlShortener::class, Service\VisitsTracker::class],
|
||||
Action\QrCodeAction::class => [RouterInterface::class, Service\UrlShortener::class, 'Logger_Shlink'],
|
||||
Action\PreviewAction::class => [PreviewGenerator::class, Service\UrlShortener::class],
|
||||
Middleware\QrCodeCacheMiddleware::class => [Cache::class],
|
||||
|
||||
@@ -7,8 +7,6 @@ use Interop\Http\ServerMiddleware\DelegateInterface;
|
||||
use Interop\Http\ServerMiddleware\MiddlewareInterface;
|
||||
use Psr\Http\Message\ResponseInterface as Response;
|
||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Psr\Log\NullLogger;
|
||||
use Shlinkio\Shlink\Core\Action\Util\ErrorResponseBuilderTrait;
|
||||
use Shlinkio\Shlink\Core\Exception\EntityDoesNotExistException;
|
||||
use Shlinkio\Shlink\Core\Exception\InvalidShortCodeException;
|
||||
@@ -28,19 +26,11 @@ class RedirectAction implements MiddlewareInterface
|
||||
* @var VisitsTrackerInterface
|
||||
*/
|
||||
private $visitTracker;
|
||||
/**
|
||||
* @var null|LoggerInterface
|
||||
*/
|
||||
private $logger;
|
||||
|
||||
public function __construct(
|
||||
UrlShortenerInterface $urlShortener,
|
||||
VisitsTrackerInterface $visitTracker,
|
||||
LoggerInterface $logger = null
|
||||
) {
|
||||
public function __construct(UrlShortenerInterface $urlShortener, VisitsTrackerInterface $visitTracker)
|
||||
{
|
||||
$this->urlShortener = $urlShortener;
|
||||
$this->visitTracker = $visitTracker;
|
||||
$this->logger = $logger ?: new NullLogger();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -60,13 +60,13 @@ class UrlShortener implements UrlShortenerInterface
|
||||
* @throws InvalidUrlException
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function urlToShortCode(UriInterface $url, array $tags = [])
|
||||
public function urlToShortCode(UriInterface $url, array $tags = []): string
|
||||
{
|
||||
// If the url already exists in the database, just return its short code
|
||||
$shortUrl = $this->em->getRepository(ShortUrl::class)->findOneBy([
|
||||
'originalUrl' => $url,
|
||||
]);
|
||||
if (isset($shortUrl)) {
|
||||
if ($shortUrl !== null) {
|
||||
return $shortUrl->getShortCode();
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ class UrlShortener implements UrlShortenerInterface
|
||||
* @throws InvalidShortCodeException
|
||||
* @throws EntityDoesNotExistException
|
||||
*/
|
||||
public function shortCodeToUrl($shortCode): string
|
||||
public function shortCodeToUrl(string $shortCode): string
|
||||
{
|
||||
$cacheKey = sprintf('%s_longUrl', $shortCode);
|
||||
// Check if the short code => URL map is already cached
|
||||
|
||||
@@ -20,7 +20,7 @@ interface UrlShortenerInterface
|
||||
* @throws InvalidUrlException
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function urlToShortCode(UriInterface $url, array $tags = []);
|
||||
public function urlToShortCode(UriInterface $url, array $tags = []): string;
|
||||
|
||||
/**
|
||||
* Tries to find the mapped URL for provided short code. Returns null if not found
|
||||
@@ -30,5 +30,5 @@ interface UrlShortenerInterface
|
||||
* @throws InvalidShortCodeException
|
||||
* @throws EntityDoesNotExistException
|
||||
*/
|
||||
public function shortCodeToUrl($shortCode): string;
|
||||
public function shortCodeToUrl(string $shortCode): string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user