Inlcuded tags as part of the ShortUrlMeta

This commit is contained in:
Alejandro Celaya
2021-01-30 19:17:12 +01:00
parent 3f2bd657e1
commit 063ee9c195
14 changed files with 60 additions and 99 deletions

View File

@@ -5,7 +5,6 @@ declare(strict_types=1);
namespace Shlinkio\Shlink\Rest\Action\ShortUrl;
use Psr\Http\Message\ServerRequestInterface as Request;
use Shlinkio\Shlink\Core\Model\CreateShortUrlData;
use Shlinkio\Shlink\Core\Model\ShortUrlMeta;
use Shlinkio\Shlink\Core\Validation\ShortUrlMetaInputFilter;
use Shlinkio\Shlink\Rest\Middleware\AuthenticationMiddleware;
@@ -15,17 +14,17 @@ class SingleStepCreateShortUrlAction extends AbstractCreateShortUrlAction
protected const ROUTE_PATH = '/short-urls/shorten';
protected const ROUTE_ALLOWED_METHODS = [self::METHOD_GET];
protected function buildShortUrlData(Request $request): CreateShortUrlData
protected function buildShortUrlData(Request $request): ShortUrlMeta
{
$query = $request->getQueryParams();
$longUrl = $query['longUrl'] ?? null;
$apiKey = AuthenticationMiddleware::apiKeyFromRequest($request);
return new CreateShortUrlData([], ShortUrlMeta::fromRawData([
return ShortUrlMeta::fromRawData([
ShortUrlMetaInputFilter::LONG_URL => $longUrl,
ShortUrlMetaInputFilter::API_KEY => $apiKey,
// This will usually be null, unless this API key enforces one specific domain
ShortUrlMetaInputFilter::DOMAIN => $request->getAttribute(ShortUrlMetaInputFilter::DOMAIN),
]));
]);
}
}