Closed jmontoyaa closed 11 years ago
Thanks for taking the time to send this PR! I'm not really sure what you mean about override the original one's because of the Pimple. When you register the provider you can do this:
$app->register(new PagerfantaServiceProvider(), array(
'pagerfanta.view.options' => array(
'routeName' => 'my_route',
'routeParams' => array('parameter1' => 'value1')
)
));
And this options are merged in the provider's boot method. Anyway reviewing this code, I think it doesn't make sense to configure this parameters when you register the provider because it will be different in every pagination, like WhiteOctoberPagerfanta does. What do you think?
Hello! Yes I agree with your comment but... I'm using controller as services and I need to override those parameters because I use it in different actions.
In my bootstrap file I have this:
$app->register(new PagerfantaServiceProvider(), array(
'pagerfanta.view.options' => array(
'routeName' =>nul,
'routeParams' => null
)
));
For example I have a controller with 2 actions but I need to generate 2 URLs like this:
class MyController
{
private $app;
public function paginationAction($page) {
$adapter = new FixedAdapter($nbResults, array());
$pagerfanta = new Pagerfanta($adapter);
$pagerfanta->setMaxPerPage($this->maxPerPage);
$pagerfanta->setCurrentPage($page); // 1 by default
$this->app['pagerfanta.view.router.name'] = 'route1'; // <<- different route
$this->app['pagerfanta.view.router.params'] = array(
'filter' => '1',
'page' => $page
);
}
public function paginationDifAction($page) {
$adapter = new FixedAdapter($nbResults, array());
$pagerfanta = new Pagerfanta($adapter);
$pagerfanta->setMaxPerPage($this->maxPerPage);
$pagerfanta->setCurrentPage($page); // 1 by default
$this->app['pagerfanta.view.router.name'] = 'route2'; // << different route
$this->app['pagerfanta.view.router.params'] = array(
'filter' => '2',
'page' => $page
);
}
}
And I can't override the original routeName and routeParams like this in every action ...
$this->app['pagerfanta.view.options']['routeName'] = 'something';
$this->app['pagerfanta.view.options']['routeParams'] = array();
Perfect, I'll merge and then I'll remove routeName
and routeParams
in the Provider registration.
One more thing, why use this version for propertyaccess:
"symfony/property-access": ">=2.2,<2.4-dev"
I mean, it is not better to rely on the 2.2 stable?
Thanks!
yes, I just change the version, sorry!
Thanks!
Sometimes you need to change the route name and route params. You can't override the original one's because of Pimple:
'routeName' => null, 'routeParams' => array()