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 configurable defaults for BootstrapPaginatorHelper #130

Open
Antoniossss opened this issue Jun 1, 2017 · 1 comment
Open

Add configurable defaults for BootstrapPaginatorHelper #130

Antoniossss opened this issue Jun 1, 2017 · 1 comment

Comments

@Antoniossss
Copy link

Antoniossss commented Jun 1, 2017

For example, I would like to globally apply following configuration so it would be to every invokation of BootstrapPaginatorhelper#numbers()

                     [
                        "size" => "small",
                        "prev" => "<",
                        "next" => ">",
                        "ellipsis" => true,
                        "first"=>"first",
                        "last"=>"last",
                    ]

Right now I have to put those options to every invocation am I correct? It would be great to have ability to confiugre those values as defaults.

I think that perfect fit would be upon helper initialization

        'Paginator' => [
            'className' => 'Bootstrap.BootstrapPaginator',
            'numbers' => [
                "size" => "small",
                "prev" => "<",
                "next" => ">",
                "ellipsis" => true,
                "first" => "first",
                "last" => "last",
            ]
        ],

And after quick glance at the source, I found out that its is all about adding 2 lines

      if ($this->getConfig("numbers")) {
            $options += $this->getConfig("numbers");
        }

at the beginning of numbers method. Clean code and handy solution.

@Holt59
Copy link
Collaborator

Holt59 commented Jun 2, 2017

Easiest way to do this is to create your own helper and override numbers:

namespace App\View\Helper;

class MyPaginatorHelper extends \Bootstrap\View\Helper\PaginatorHelper {

    public function numbers(array $options = []) {
        $options += [
            "size" => "small",
            "prev" => "<",
            "next" => ">",
            "ellipsis" => true,
            "first" => "first",
            "last" => "last",
        ];
        return parent::numbers($options);
    }

}

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

2 participants