Customizing Pagination in Listview

I’m trying to customize the pagination in a listview, so that I can alter the route of the page links.

I have two paths to a model view depending on the context.

In the second context I have a url rule to re-route to the correct controller as follows:-




               [ 

                            'pattern' => 'destination/<name:.*>',

                            'route' => '/locality/view',

                            'defaults' => ['destination'=>'true'],

                    ],



So this adds a parameter "destination"=>true

I have then tried to modify the pagination in this view context as follows:-





        $pageCount = $searchModel->count;

        $pagination = new Pagination([

                'route' =>  $locality->url,

                'totalCount' => $pageCount,

                //'params' => [ 'page'=>$page],

                'urlManager' => SUrlManager::className()

        ]);

        

        var_dump( $pagination );

        echo ListView::widget([

                    'dataProvider' => $dataProvider,

                    'itemView' => '//search/_properties',

                    'viewParams' => [ ... ],

                    'itemOptions' => [

                        'tag' => 'li',

                        'class' => 'result-item'

                    ],

                    'pager' => [

                            'maxButtonCount' => 10,

                            'class' => SLinkPager::className(),

                            'pagination' => $pagination

                        ],

                     ...

          ]);




My SlinkPager class extends linkPager and var-dumps $pagination in init(0





namespace frontend\components;


use yii\widgets\LinkPager;


class SLinkPager extends LinkPager

{

    

    public function init()

    {

        var_dump( $this->pagination );

        return parent::init();

    }

}



So I have a var_dump when I create the pagination object. this shows all the attributes as I would expect:-




object(yii\data\Pagination)[321]

  public 'pageParam' => string 'page' (length=4)

  public 'pageSizeParam' => string 'per-page' (length=<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/cool.gif' class='bbc_emoticon' alt='8)' />

  public 'forcePageParam' => boolean true

  public 'route' => string '/destination/french-alps' (length=24)

  public 'params' => null

  public 'urlManager' => string 'frontend\components\SUrlManager' (length=31)

  public 'validatePage' => boolean true

  public 'totalCount' => int 23

  public 'defaultPageSize' => int 20

  public 'pageSizeLimit' => 

    array (size=2)

      0 => int 1

      1 => int 50

  private '_pageSize' => null

  private '_page' => null



However, when SLinkPager var_dumps the $pagination object it doesn’t - except the totalCount




object(yii\data\Pagination)[316]

  public 'pageParam' => string 'page' (length=4)

  public 'pageSizeParam' => string 'per-page' (length=<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/cool.gif' class='bbc_emoticon' alt='8)' />

  public 'forcePageParam' => boolean true

  public 'route' => null

  public 'params' => null

  public 'urlManager' => null

  public 'validatePage' => boolean true

  public 'totalCount' => int 23

  public 'defaultPageSize' => int 20

  public 'pageSizeLimit' => 

    array (size=2)

      0 => int 1

      1 => int 50

  private '_pageSize' => int 15

  private '_page' => int 0



Any ideas what I might be doing wrong?