0

I am using sonataAdminBundle pagination. There is this Sonata\AdminBundle\Admin\Admin class which has a property called $maxPerPage = 25;

So how do i override this class in services.yml file so that all my other admin classes can have pagination without repeating code.

Thanks!

M Khalid Junaid
  • 63,861
  • 10
  • 90
  • 118

1 Answers1

0

I guess there is no direct way to change it but you can manage it by creating one base admin and all your admin classes will extend your base admin, once you have a base admin class which directly inherits sonata's admin class then you in constructor function you can define your limit of records using datagridValues's _per_page index

use Sonata\AdminBundle\Admin\Admin;
class BaseAdmin extends Admin {
    public function __construct( $code, $class, $baseControllerName ) {
        parent::__construct( $code, $class, $baseControllerName );
            $this->datagridValues = array(
                '_page'       => 1,
                '_per_page'   => 50,
                /** '_sort_order' => 'DESC',      // sort direction */

            );
    }
}
M Khalid Junaid
  • 63,861
  • 10
  • 90
  • 118