Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add entry point to support more PagerType #1712

Open
VincentLanglet opened this issue Jan 25, 2023 · 1 comment
Open

Add entry point to support more PagerType #1712

VincentLanglet opened this issue Jan 25, 2023 · 1 comment

Comments

@VincentLanglet
Copy link
Member

Feature Request

A PagerFactory could be provided by this library:

final PagerFactory implements PagerFactoryInterface
{
     public function create(string $pagerType): PagerInterface
     {
          switch ($pagerType) {
            case Pager::TYPE_DEFAULT:
                return new Pager();

            case Pager::TYPE_SIMPLE:
                /** @var SimplePager<ProxyQueryInterface<object>> $simplePager */
                $simplePager = new SimplePager();

                return $simplePager;

            default:
                throw new \RuntimeException(sprintf('Unknown pager type "%s".', $pagerType));
        }
    }
}

then we could change the following code
https://github.com/sonata-project/SonataDoctrineORMAdminBundle/blob/4.x/src/Builder/DatagridBuilder.php#L147
to

$pager = $this->pagerFactory->create($admin->getPagerType());

And people will be able to support new pagerType or override the page easily.

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant