mirror of
https://github.com/shlinkio/shlink.git
synced 2024-11-22 08:56:42 -06:00
Added current page message in list short urls CLI command
This commit is contained in:
parent
bb40d84212
commit
1983fc9b67
@ -126,7 +126,10 @@ class ListShortUrlsCommand extends Command
|
||||
$rows[] = array_values($shortUrl);
|
||||
}
|
||||
|
||||
ShlinkTable::fromOutput($output)->render($headers, $rows);
|
||||
ShlinkTable::fromOutput($output)->render($headers, $rows, $this->formatCurrentPageMessage(
|
||||
$result,
|
||||
'Page %s of %s'
|
||||
));
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ final class ShlinkTable
|
||||
return new self(new Table($output));
|
||||
}
|
||||
|
||||
public function render(array $headers, array $rows, ?string $headerTitle = null, ?string $footerTitle = null): void
|
||||
public function render(array $headers, array $rows, ?string $footerTitle = null, ?string $headerTitle = null): void
|
||||
{
|
||||
$style = Table::getStyleDefinition(self::DEFAULT_STYLE_NAME);
|
||||
$style->setFooterTitleFormat(self::TABLE_TITLE_STYLE)
|
||||
@ -34,8 +34,8 @@ final class ShlinkTable
|
||||
$table->setStyle($style)
|
||||
->setHeaders($headers)
|
||||
->setRows($rows)
|
||||
->setHeaderTitle($headerTitle)
|
||||
->setFooterTitle($footerTitle)
|
||||
->setHeaderTitle($headerTitle)
|
||||
->render();
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
namespace Shlinkio\Shlink\Common\Paginator\Util;
|
||||
|
||||
use Shlinkio\Shlink\Common\Rest\DataTransformerInterface;
|
||||
use function sprintf;
|
||||
use Zend\Paginator\Paginator;
|
||||
use Zend\Stdlib\ArrayUtils;
|
||||
use function array_map;
|
||||
@ -39,4 +40,9 @@ trait PaginatorUtilsTrait
|
||||
{
|
||||
return $paginator->getCurrentPageNumber() >= $paginator->count();
|
||||
}
|
||||
|
||||
private function formatCurrentPageMessage(Paginator $paginator, string $pattern): string
|
||||
{
|
||||
return sprintf($pattern, $paginator->getCurrentPageNumber(), $paginator->count());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user