mirror of
https://github.com/shlinkio/shlink.git
synced 2026-08-14 06:54:41 -05:00
Remove requirement of checker props in ShortUrlEdition
This commit is contained in:
@@ -60,10 +60,7 @@ final class ShortUrlDataInput
|
|||||||
'validSinceWasProvided' => $this->validSince !== null,
|
'validSinceWasProvided' => $this->validSince !== null,
|
||||||
'validUntilWasProvided' => $this->validUntil !== null,
|
'validUntilWasProvided' => $this->validUntil !== null,
|
||||||
'maxVisitsWasProvided' => $this->maxVisits !== null,
|
'maxVisitsWasProvided' => $this->maxVisits !== null,
|
||||||
'tagsWereProvided' => $this->tags !== null,
|
|
||||||
'titleWasProvided' => $this->title !== null,
|
'titleWasProvided' => $this->title !== null,
|
||||||
'crawlableWasProvided' => $this->crawlable !== null,
|
|
||||||
'forwardQueryWasProvided' => $this->noForwardQuery !== null,
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -147,14 +147,14 @@ class ShortUrl extends AbstractEntity
|
|||||||
if ($shortUrlEdit->maxVisitsWasProvided) {
|
if ($shortUrlEdit->maxVisitsWasProvided) {
|
||||||
$this->maxVisits = $shortUrlEdit->maxVisits;
|
$this->maxVisits = $shortUrlEdit->maxVisits;
|
||||||
}
|
}
|
||||||
if ($shortUrlEdit->longUrlWasProvided) {
|
if ($shortUrlEdit->longUrl !== null) {
|
||||||
$this->longUrl = $shortUrlEdit->longUrl ?? $this->longUrl;
|
$this->longUrl = $shortUrlEdit->longUrl;
|
||||||
}
|
}
|
||||||
if ($shortUrlEdit->tagsWereProvided) {
|
if ($shortUrlEdit->tags !== null) {
|
||||||
$relationResolver = $relationResolver ?? new SimpleShortUrlRelationResolver();
|
$relationResolver = $relationResolver ?? new SimpleShortUrlRelationResolver();
|
||||||
$this->tags = $relationResolver->resolveTags($shortUrlEdit->tags);
|
$this->tags = $relationResolver->resolveTags($shortUrlEdit->tags);
|
||||||
}
|
}
|
||||||
if ($shortUrlEdit->crawlableWasProvided) {
|
if ($shortUrlEdit->crawlable !== null) {
|
||||||
$this->crawlable = $shortUrlEdit->crawlable;
|
$this->crawlable = $shortUrlEdit->crawlable;
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
@@ -165,7 +165,7 @@ class ShortUrl extends AbstractEntity
|
|||||||
$this->title = $shortUrlEdit->title;
|
$this->title = $shortUrlEdit->title;
|
||||||
$this->titleWasAutoResolved = $shortUrlEdit->titleWasAutoResolved;
|
$this->titleWasAutoResolved = $shortUrlEdit->titleWasAutoResolved;
|
||||||
}
|
}
|
||||||
if ($shortUrlEdit->forwardQueryWasProvided) {
|
if ($shortUrlEdit->forwardQuery !== null) {
|
||||||
$this->forwardQuery = $shortUrlEdit->forwardQuery;
|
$this->forwardQuery = $shortUrlEdit->forwardQuery;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,14 +18,8 @@ final class ShortUrlEdition implements TitleResolutionModelInterface
|
|||||||
public Chronos|null $validSince;
|
public Chronos|null $validSince;
|
||||||
public Chronos|null $validUntil;
|
public Chronos|null $validUntil;
|
||||||
|
|
||||||
// phpcs:disable PSR2.Classes.PropertyDeclaration.Multiple
|
|
||||||
public bool $longUrlWasProvided {
|
|
||||||
// phpcs:disable PSR2.Classes.PropertyDeclaration.ScopeMissing
|
|
||||||
get => $this->longUrl !== null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string[] $tags
|
* @param string[]|null $tags
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
#[LooseUriConverter]
|
#[LooseUriConverter]
|
||||||
@@ -36,17 +30,14 @@ final class ShortUrlEdition implements TitleResolutionModelInterface
|
|||||||
DateTimeInterface|string|null $validUntil = null,
|
DateTimeInterface|string|null $validUntil = null,
|
||||||
readonly public bool $maxVisitsWasProvided = false,
|
readonly public bool $maxVisitsWasProvided = false,
|
||||||
readonly public int|null $maxVisits = null,
|
readonly public int|null $maxVisits = null,
|
||||||
readonly public bool $tagsWereProvided = false,
|
|
||||||
#[TagsConverter]
|
#[TagsConverter]
|
||||||
readonly public array $tags = [],
|
readonly public array|null $tags = null,
|
||||||
readonly public bool $titleWasProvided = false,
|
readonly public bool $titleWasProvided = false,
|
||||||
#[SubstringConverter(512)]
|
#[SubstringConverter(512)]
|
||||||
readonly public string|null $title = null,
|
readonly public string|null $title = null,
|
||||||
readonly public bool $titleWasAutoResolved = false,
|
readonly public bool $titleWasAutoResolved = false,
|
||||||
readonly public bool $crawlableWasProvided = false,
|
readonly public bool|null $crawlable = null,
|
||||||
readonly public bool $crawlable = false,
|
readonly public bool|null $forwardQuery = null,
|
||||||
readonly public bool $forwardQueryWasProvided = false,
|
|
||||||
readonly public bool $forwardQuery = true,
|
|
||||||
) {
|
) {
|
||||||
$this->validSince = normalizeOptionalDate($validSince);
|
$this->validSince = normalizeOptionalDate($validSince);
|
||||||
$this->validUntil = normalizeOptionalDate($validUntil);
|
$this->validUntil = normalizeOptionalDate($validUntil);
|
||||||
@@ -68,14 +59,11 @@ final class ShortUrlEdition implements TitleResolutionModelInterface
|
|||||||
validUntil: $this->validUntil,
|
validUntil: $this->validUntil,
|
||||||
maxVisitsWasProvided: $this->maxVisitsWasProvided,
|
maxVisitsWasProvided: $this->maxVisitsWasProvided,
|
||||||
maxVisits: $this->maxVisits,
|
maxVisits: $this->maxVisits,
|
||||||
tagsWereProvided: $this->tagsWereProvided,
|
|
||||||
tags: $this->tags,
|
tags: $this->tags,
|
||||||
titleWasProvided: $this->titleWasProvided,
|
titleWasProvided: $this->titleWasProvided,
|
||||||
title: $title,
|
title: $title,
|
||||||
titleWasAutoResolved: true,
|
titleWasAutoResolved: true,
|
||||||
crawlableWasProvided: $this->crawlableWasProvided,
|
|
||||||
crawlable: $this->crawlable,
|
crawlable: $this->crawlable,
|
||||||
forwardQueryWasProvided: $this->forwardQueryWasProvided,
|
|
||||||
forwardQuery: $this->forwardQuery,
|
forwardQuery: $this->forwardQuery,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ readonly class ShortUrlService implements ShortUrlServiceInterface
|
|||||||
ShortUrlEdition $shortUrlEdit,
|
ShortUrlEdition $shortUrlEdit,
|
||||||
ApiKey|null $apiKey = null,
|
ApiKey|null $apiKey = null,
|
||||||
): ShortUrl {
|
): ShortUrl {
|
||||||
if ($shortUrlEdit->longUrlWasProvided) {
|
if ($shortUrlEdit->longUrl !== null) {
|
||||||
$shortUrlEdit = $this->titleResolutionHelper->processTitle($shortUrlEdit);
|
$shortUrlEdit = $this->titleResolutionHelper->processTitle($shortUrlEdit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,10 +37,7 @@ class EditShortUrlAction extends AbstractRestAction
|
|||||||
'validSinceWasProvided' => array_key_exists('validSince', $body),
|
'validSinceWasProvided' => array_key_exists('validSince', $body),
|
||||||
'validUntilWasProvided' => array_key_exists('validUntil', $body),
|
'validUntilWasProvided' => array_key_exists('validUntil', $body),
|
||||||
'maxVisitsWasProvided' => array_key_exists('maxVisits', $body),
|
'maxVisitsWasProvided' => array_key_exists('maxVisits', $body),
|
||||||
'tagsWereProvided' => array_key_exists('tags', $body),
|
|
||||||
'titleWasProvided' => array_key_exists('title', $body),
|
'titleWasProvided' => array_key_exists('title', $body),
|
||||||
'crawlableWasProvided' => array_key_exists('crawlable', $body),
|
|
||||||
'forwardQueryWasProvided' => array_key_exists('forwardQuery', $body),
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$identifier = ShortUrlIdentifier::fromApiRequest($request);
|
$identifier = ShortUrlIdentifier::fromApiRequest($request);
|
||||||
|
|||||||
Reference in New Issue
Block a user