mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-06 23:33:13 +08:00
Ensure filtering of custom-slug is different depending on the multi-sement lugsfeature flag
This commit is contained in:
@@ -61,10 +61,15 @@ return [
|
||||
|
||||
Action\HealthAction::class => ['em', Options\AppOptions::class],
|
||||
Action\MercureInfoAction::class => [LcobucciJwtProvider::class, 'config.mercure'],
|
||||
Action\ShortUrl\CreateShortUrlAction::class => [Service\UrlShortener::class, ShortUrlDataTransformer::class],
|
||||
Action\ShortUrl\CreateShortUrlAction::class => [
|
||||
Service\UrlShortener::class,
|
||||
ShortUrlDataTransformer::class,
|
||||
Options\UrlShortenerOptions::class,
|
||||
],
|
||||
Action\ShortUrl\SingleStepCreateShortUrlAction::class => [
|
||||
Service\UrlShortener::class,
|
||||
ShortUrlDataTransformer::class,
|
||||
Options\UrlShortenerOptions::class,
|
||||
],
|
||||
Action\ShortUrl\EditShortUrlAction::class => [Service\ShortUrlService::class, ShortUrlDataTransformer::class],
|
||||
Action\ShortUrl\DeleteShortUrlAction::class => [Service\ShortUrl\DeleteShortUrlService::class],
|
||||
|
||||
@@ -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,
|
||||
) {
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ use Shlinkio\Shlink\Common\Rest\DataTransformerInterface;
|
||||
use Shlinkio\Shlink\Core\Entity\ShortUrl;
|
||||
use Shlinkio\Shlink\Core\Exception\ValidationException;
|
||||
use Shlinkio\Shlink\Core\Model\ShortUrlMeta;
|
||||
use Shlinkio\Shlink\Core\Options\UrlShortenerOptions;
|
||||
use Shlinkio\Shlink\Core\Service\UrlShortener;
|
||||
use Shlinkio\Shlink\Rest\Action\ShortUrl\CreateShortUrlAction;
|
||||
use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
||||
@@ -34,7 +35,11 @@ class CreateShortUrlActionTest extends TestCase
|
||||
$this->transformer = $this->prophesize(DataTransformerInterface::class);
|
||||
$this->transformer->transform(Argument::type(ShortUrl::class))->willReturn([]);
|
||||
|
||||
$this->action = new CreateShortUrlAction($this->urlShortener->reveal(), $this->transformer->reveal());
|
||||
$this->action = new CreateShortUrlAction(
|
||||
$this->urlShortener->reveal(),
|
||||
$this->transformer->reveal(),
|
||||
new UrlShortenerOptions(),
|
||||
);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
|
||||
@@ -12,6 +12,7 @@ use Prophecy\Prophecy\ObjectProphecy;
|
||||
use Shlinkio\Shlink\Common\Rest\DataTransformerInterface;
|
||||
use Shlinkio\Shlink\Core\Entity\ShortUrl;
|
||||
use Shlinkio\Shlink\Core\Model\ShortUrlMeta;
|
||||
use Shlinkio\Shlink\Core\Options\UrlShortenerOptions;
|
||||
use Shlinkio\Shlink\Core\Service\UrlShortenerInterface;
|
||||
use Shlinkio\Shlink\Rest\Action\ShortUrl\SingleStepCreateShortUrlAction;
|
||||
use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
||||
@@ -33,6 +34,7 @@ class SingleStepCreateShortUrlActionTest extends TestCase
|
||||
$this->action = new SingleStepCreateShortUrlAction(
|
||||
$this->urlShortener->reveal(),
|
||||
$this->transformer->reveal(),
|
||||
new UrlShortenerOptions(),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user