mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-09 16:53:11 +08:00
Added support to print all short URLs at once from CLI
This commit is contained in:
@@ -5,10 +5,13 @@ declare(strict_types=1);
|
||||
namespace Shlinkio\Shlink\Core\Validation;
|
||||
|
||||
use Laminas\Filter;
|
||||
use Laminas\InputFilter\Input;
|
||||
use Laminas\InputFilter\InputFilter;
|
||||
use Laminas\Validator;
|
||||
use Shlinkio\Shlink\Common\Validation;
|
||||
|
||||
use function is_numeric;
|
||||
|
||||
class ShortUrlsParamsInputFilter extends InputFilter
|
||||
{
|
||||
use Validation\InputFactoryTrait;
|
||||
@@ -18,6 +21,7 @@ class ShortUrlsParamsInputFilter extends InputFilter
|
||||
public const TAGS = 'tags';
|
||||
public const START_DATE = 'startDate';
|
||||
public const END_DATE = 'endDate';
|
||||
public const ITEMS_PER_PAGE = 'itemsPerPage';
|
||||
|
||||
public function __construct(array $data)
|
||||
{
|
||||
@@ -32,14 +36,22 @@ class ShortUrlsParamsInputFilter extends InputFilter
|
||||
|
||||
$this->add($this->createInput(self::SEARCH_TERM, false));
|
||||
|
||||
$page = $this->createInput(self::PAGE, false);
|
||||
$page->getValidatorChain()->attach(new Validator\Digits())
|
||||
->attach(new Validator\GreaterThan(['min' => 1, 'inclusive' => true]));
|
||||
$this->add($page);
|
||||
$this->add($this->createNumericInput(self::PAGE, 1));
|
||||
|
||||
$tags = $this->createArrayInput(self::TAGS, false);
|
||||
$tags->getFilterChain()->attach(new Filter\StringToLower())
|
||||
->attach(new Filter\PregReplace(['pattern' => '/ /', 'replacement' => '-']));
|
||||
$this->add($tags);
|
||||
|
||||
$this->add($this->createNumericInput(self::ITEMS_PER_PAGE, -1));
|
||||
}
|
||||
|
||||
private function createNumericInput(string $name, int $min): Input
|
||||
{
|
||||
$input = $this->createInput($name, false);
|
||||
$input->getValidatorChain()->attach(new Validator\Callback(fn ($value) => is_numeric($value)))
|
||||
->attach(new Validator\GreaterThan(['min' => $min, 'inclusive' => true]));
|
||||
|
||||
return $input;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user