Routing: differences between different return types

I think it is very confusing that the docs state that “[a]n action must either return a page object, a response object, redirect to a different URL or exit the code execution by returning false” but misses to explain the consequences the different “return types” have.

It seems like they are all equal and the examples in the docs use them seemingly interchangeable. But as I just had to find out for myself there are differences between simply returning a page object, an array with a page uid and additional data or using site()->visit($page). In the latter for example $page->isOpen and $page->isActive are working, in the former not.

Or am I missing something?

No, that is correct, for $page->isActive() or. isOpen()``to work, you need to actually set site::page to the page you are retrieving.

I’ll add a note to the documentation.

Thank you!

In addition to that: what do I do, if I want to return additional data with return array('some/page', $data); and want isOpen or isActive to be working?

You can do one. of two. things:

  1. two steps:

    return array('some/page', $data);
  2. all in one:

    return array(site()->visit('some/page'), $data);

Thank you again! Works perfectly.