This method is mainly called by pagers when creating URLs used to perform pagination.
public createUrl ( integer $page, integer $pageSize = null, boolean $absolute = false ) : string | ||
$page | integer | the zero-based page number that the URL should point to. |
$pageSize | integer | the number of items on each page. If not set, the value of [[pageSize]] will be used. |
$absolute | boolean | whether to create an absolute URL. Defaults to `false`. |
Результат | string | the created URL |
/** * @depends testCreateUrl */ public function testForcePageParam() { $pagination = new Pagination(); $pagination->route = 'item/list'; $pagination->forcePageParam = true; $this->assertEquals('/index.php?r=item%2Flist&page=1', $pagination->createUrl(0)); $pagination->forcePageParam = false; $this->assertEquals('/index.php?r=item%2Flist', $pagination->createUrl(0)); }
public function createUrl($page, $pageSize = null, $absolute = false) { $url = parent::createUrl($page, $pageSize, $absolute); if (!$absolute) { return \Yii::$app->params['static_host'] . '/' . ltrim($url, '/'); } else { return $url; } }