I'm using 3.1.13 SilverStripe CMS and Framework. I have ran into troubles after creating a function inside my Page.php (class Page) and initializing it in my views (page.ss). I want to create a pagination for my project. Here is my error with source and trace:
[User Error] Uncaught Exception: The request must be readable as an array.
GET /?flushtoken=88455a3cc5497ee38dd7a61d75370221&flush=all
Line 28 in /var/www/project-name/framework/core/PaginatedList.php
Source
19 * Constructs a new paginated list instance around a list.
20 *
21 * @param SS_List $list The list to paginate. The getRange method will
22 * be used to get the subset of objects to show.
23 * @param array|ArrayAccess Either a map of request parameters or
24 * request object that the pagination offset is read from.
25 */
26 public function __construct(SS_List $list, $request = array()) {
27 if (!is_array($request) && !$request instanceof ArrayAccess) {
28 throw new Exception('The request must be readable as an array.');
29 }
30
31 $this->request = $request;
32 parent::__construct($list);
33 }
34
Trace
PaginatedList->__construct(DataList,)
HomePage.php:182
HomePage->PaginatedPages()
call_user_func_array(Array,Array)
Object.php:731
Object->__call(PaginatedPages,Array)
ViewableData.php:361
HomePage_Controller->PaginatedPages()
ViewableData.php:361
ViewableData->obj(PaginatedPages,,1,,)
SSViewer.php:91
SSViewer_Scope->getObj(PaginatedPages,,1,,)
SSViewer.php:504
SSViewer_DataPresenter->getObj(PaginatedPages,,1,,)
SSViewer.php:111
SSViewer_Scope->obj(PaginatedPages,,1)
.cache.themes.project-name.templates.Layout.HomePage.ss:400
include(/tmp/silverstripe-cache-php5.5.9-1ubuntu4.11-var-www-project-name/www-data/.cache.themes.project-name.templates.Layout.HomePage.ss)
SSViewer.php:1031
SSViewer->includeGeneratedTemplate(/tmp/silverstripe-cache-php5.5.9-1ubuntu4.11-var-www-project-name/www-data/.cache.themes.project-name.templates.Layout.HomePage.ss,HomePage_Controller,,Array,)
SSViewer.php:1098
SSViewer->process(HomePage_Controller,)
SSViewer.php:1094
SSViewer->process(HomePage_Controller)
Controller.php:203
Controller->handleAction(SS_HTTPRequest,index)
RequestHandler.php:200
RequestHandler->handleRequest(SS_HTTPRequest,DataModel)
Controller.php:153
Controller->handleRequest(SS_HTTPRequest,DataModel)
ContentController.php:198
ContentController->handleRequest(SS_HTTPRequest,DataModel)
ModelAsController.php:78
ModelAsController->handleRequest(SS_HTTPRequest,DataModel)
RootURLController.php:130
RootURLController->handleRequest(SS_HTTPRequest,DataModel)
Director.php:370
Director::handleRequest(SS_HTTPRequest,Session,DataModel)
Director.php:153
Director::direct(/,DataModel)
main.php:177
Where is the problem? I'm following this instructions and it fails when I'm calling my function in the view.