定制 turbolabit/paginatorbundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

turbolabit/paginatorbundle

Composer 安装命令:

composer require turbolabit/paginatorbundle

包简介

README 文档

README

A simple Symfony bundle to render the "classic" pagination element.

It also works without Symfony, as a plain PHP object.

📦 Install it with composer

symfony composer require turbolabit/paginatorbundle:dev-main

🏗️ Use it

src/Service/Paginator.php

<?php
namespace App\Service;

use \TurboLabIt\PaginatorBundle\Service\Paginator as BasePaginator;


class Paginator extends BasePaginator
{
    protected string $pageParam = 'p';
    protected int $slotNum      = 5;
}

src/Controller/ListingController.php

<?php
namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use App\Service\Paginator;


class ListingController extends AbstractController
{
    protected Request $request;


    public function __construct(RequestStack $requestStack, protected Paginator $paginator)
    {
        $this->request = $requestStack->getCurrentRequest();
    }


    #[Route('/{categorySlug}/', name: 'app_listing', priority: -99)]
    public function listing(string $categorySlug) : Response
    {
        $currentPage    = $this->request->get('p') ?? 1; 
        $totalPages     = 99;
        $oPages =
            $this->paginator
                ->setBaseUrl('/' . $categorySlug . '/')
                ->build($currentPage, $totalPages);

        return $this->render('listing.html.twig', [
            'page'      => $currentPage,
            'Pages'     => $oPages
        ]);
    }
}

🧪 Test it

bash scripts/symfony-bundle-tester.sh

统计信息

  • 总下载量: 624
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: CC-BY-4.0
  • 更新时间: 2024-07-13