Skip to content

Commit fa36dcb

Browse files
committed
[BrowserKit] Add isFirstPage() and isLastPage() methods to History
1 parent c7ce246 commit fa36dcb

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

components/browser_kit.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,20 @@ history::
329329
// go forward to documentation page
330330
$crawler = $client->forward();
331331

332+
// check if the history position is on the first page
333+
if (!$client->history()->isFirstPage()) {
334+
$crawler = $client->back();
335+
}
336+
337+
// check if the history position is on the last page
338+
if (!$client->history()->isLastPage()) {
339+
$crawler = $client->forward();
340+
}
341+
342+
.. versionadded:: 7.4
343+
344+
The ``isFirstPage`` and ``isLastPage`` methods were introduced in Symfony 7.4.
345+
332346
You can delete the client's history with the ``restart()`` method. This will
333347
also delete all the cookies::
334348

0 commit comments

Comments
 (0)