Added new crawlable flag to Short URLs

This commit is contained in:
Alejandro Celaya
2021-05-22 07:35:47 +02:00
parent 2e6b3c0561
commit 348e34d52e
10 changed files with 74 additions and 0 deletions

View File

@@ -30,6 +30,8 @@ final class ShortUrlEdit implements TitleResolutionModelInterface
private ?string $title = null;
private bool $titleWasAutoResolved = false;
private ?bool $validateUrl = null;
private bool $crawlablePropWasProvided = false;
private bool $crawlable = false;
private function __construct()
{
@@ -61,6 +63,7 @@ final class ShortUrlEdit implements TitleResolutionModelInterface
$this->maxVisitsPropWasProvided = array_key_exists(ShortUrlInputFilter::MAX_VISITS, $data);
$this->tagsPropWasProvided = array_key_exists(ShortUrlInputFilter::TAGS, $data);
$this->titlePropWasProvided = array_key_exists(ShortUrlInputFilter::TITLE, $data);
$this->crawlablePropWasProvided = array_key_exists(ShortUrlInputFilter::CRAWLABLE, $data);
$this->longUrl = $inputFilter->getValue(ShortUrlInputFilter::LONG_URL);
$this->validSince = parseDateField($inputFilter->getValue(ShortUrlInputFilter::VALID_SINCE));
@@ -69,6 +72,7 @@ final class ShortUrlEdit implements TitleResolutionModelInterface
$this->validateUrl = getOptionalBoolFromInputFilter($inputFilter, ShortUrlInputFilter::VALIDATE_URL);
$this->tags = $inputFilter->getValue(ShortUrlInputFilter::TAGS);
$this->title = $inputFilter->getValue(ShortUrlInputFilter::TITLE);
$this->crawlable = $inputFilter->getValue(ShortUrlInputFilter::CRAWLABLE);
}
public function longUrl(): ?string
@@ -162,4 +166,14 @@ final class ShortUrlEdit implements TitleResolutionModelInterface
{
return $this->validateUrl;
}
public function crawlable(): bool
{
return $this->crawlable;
}
public function crawlableWasProvided(): bool
{
return $this->crawlablePropWasProvided;
}
}

View File

@@ -31,6 +31,7 @@ final class ShortUrlMeta implements TitleResolutionModelInterface
private array $tags = [];
private ?string $title = null;
private bool $titleWasAutoResolved = false;
private bool $crawlable = false;
private function __construct()
{
@@ -80,6 +81,7 @@ final class ShortUrlMeta implements TitleResolutionModelInterface
$this->apiKey = $inputFilter->getValue(ShortUrlInputFilter::API_KEY);
$this->tags = $inputFilter->getValue(ShortUrlInputFilter::TAGS);
$this->title = $inputFilter->getValue(ShortUrlInputFilter::TITLE);
$this->crawlable = $inputFilter->getValue(ShortUrlInputFilter::CRAWLABLE);
}
public function getLongUrl(): string
@@ -188,4 +190,9 @@ final class ShortUrlMeta implements TitleResolutionModelInterface
return $copy;
}
public function isCrawlable(): bool
{
return $this->crawlable;
}
}