How can I access the content from a page within the routes?
I’ve got a route like this:
array(
"pattern" => "api/v2/openhours/(:any)",
"method" => "GET",
"action" => function ($attraction) {
$attractionInfo = page("booking/" . $attraction);
if (!$attractionInfo) {
return response::json(array(
"code" => "A001",
"message" => "Attraction does not exist, please check your input."
));
}
return response::json(array(
"opening" => "world",
"host" => $_SERVER["HTTP_HOST"],
"test" => $attractionInfo->open()
));
}
)
When I check the specific route, I don’t get any response, but if I do eg. print_r() of $attractionInfo->open(), it shows me that I have to specify it to be $attractionInfo->open()->value() for it to get the value stored in it.
This is what I get when I do print_r
Field Object
(
[page] => booking/prison-island
[key] => open
[value] => 11
)