Ensure filtering of custom-slug is different depending on the multi-sement lugsfeature flag

This commit is contained in:
Alejandro Celaya
2022-08-05 08:38:05 +02:00
parent 6834e72c4a
commit fc0d99be41
13 changed files with 82 additions and 24 deletions

View File

@@ -10,14 +10,16 @@ use Psr\Http\Message\ServerRequestInterface as Request;
use Shlinkio\Shlink\Common\Rest\DataTransformerInterface;
use Shlinkio\Shlink\Core\Exception\ValidationException;
use Shlinkio\Shlink\Core\Model\ShortUrlMeta;
use Shlinkio\Shlink\Core\Options\UrlShortenerOptions;
use Shlinkio\Shlink\Core\Service\UrlShortenerInterface;
use Shlinkio\Shlink\Rest\Action\AbstractRestAction;
abstract class AbstractCreateShortUrlAction extends AbstractRestAction
{
public function __construct(
private UrlShortenerInterface $urlShortener,
private DataTransformerInterface $transformer,
private readonly UrlShortenerInterface $urlShortener,
private readonly DataTransformerInterface $transformer,
protected readonly UrlShortenerOptions $urlShortenerOptions,
) {
}

View File

@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Shlinkio\Shlink\Rest\Action\ShortUrl;
use Psr\Http\Message\ServerRequestInterface as Request;
use Shlinkio\Shlink\Core\Config\EnvVars;
use Shlinkio\Shlink\Core\Exception\ValidationException;
use Shlinkio\Shlink\Core\Model\ShortUrlMeta;
use Shlinkio\Shlink\Core\Validation\ShortUrlInputFilter;
@@ -22,6 +23,7 @@ class CreateShortUrlAction extends AbstractCreateShortUrlAction
{
$payload = (array) $request->getParsedBody();
$payload[ShortUrlInputFilter::API_KEY] = AuthenticationMiddleware::apiKeyFromRequest($request);
$payload[EnvVars::MULTI_SEGMENT_SLUGS_ENABLED->value] = $this->urlShortenerOptions->multiSegmentSlugsEnabled();
return ShortUrlMeta::fromRawData($payload);
}