Refactor Visitor model and allow a Location object to be passed to it

This commit is contained in:
Alejandro Celaya
2024-11-14 14:48:18 +01:00
parent 1fee745786
commit 4a0b7e3fc9
17 changed files with 131 additions and 87 deletions

View File

@@ -18,6 +18,7 @@ use Psr\Http\Message\ServerRequestInterface;
use Shlinkio\Shlink\Common\Middleware\IpAddressMiddlewareFactory;
use Shlinkio\Shlink\Common\Util\DateRange;
use Shlinkio\Shlink\Core\ShortUrl\Model\ShortUrlMode;
use Shlinkio\Shlink\IpGeolocation\Model\Location;
use function array_keys;
use function array_map;
@@ -289,3 +290,8 @@ function ipAddressFromRequest(ServerRequestInterface $request): string|null
{
return $request->getAttribute(IpAddressMiddlewareFactory::REQUEST_ATTR);
}
function geolocationFromRequest(ServerRequestInterface $request): Location|null
{
return $request->getAttribute(Location::class);
}