D
Deleted member 110473
Guest
Code:
An exception occurred: [TypeError] Argument 1 passed to Pages\Providers::getData() must be an instance of XF\Pub\Controller\AbstractController, string given in src/addons/Pages/Providers.php on line 23
Pages\Providers::getData()
call_user_func() in src/XF/Template/Templater.php at line 1382
XF\Template\Templater->callback() in internal_data/code_cache/templates/l1/s2/public/_page_node.100.php at line 13
XF\Template\Templater->{closure}() in src/XF/Template/Templater.php at line 1294
XF\Template\Templater->renderTemplate() in src/XF/Template/Templater.php at line 1367
XF\Template\Templater->includeTemplate() in internal_data/code_cache/templates/l1/s2/public/page_view.php at line 82
XF\Template\Templater->{closure}() in src/XF/Template/Templater.php at line 1294
XF\Template\Templater->renderTemplate() in src/XF/Template/Template.php at line 24
XF\Template\Template->render() in src/XF/Mvc/Renderer/Html.php at line 48
XF\Mvc\Renderer\Html->renderView() in src/XF/Mvc/Dispatcher.php at line 418
XF\Mvc\Dispatcher->renderView() in src/XF/Mvc/Dispatcher.php at line 400
XF\Mvc\Dispatcher->renderReply() in src/XF/Mvc/Dispatcher.php at line 360
XF\Mvc\Dispatcher->render() in src/XF/Mvc/Dispatcher.php at line 53
XF\Mvc\Dispatcher->run() in src/XF/App.php at line 2177
XF\App->run() in src/XF.php at line 390
XF::runApp() in index.php at line 20
I can't figure out what I am doing wrong... the callback is included in a node that's a Page: Pages\Providers::getData(), and the xF's admin panel for Pages says that the callback arguments are:
- \XF\Pub\Controller\AbstractController $controller
The controller instance. From this you can inspect the request, response etc. - \XF\Mvc\Reply\AbstractReply &$reply
The standard reply from the page controller.
PHP:
<?php
namespace Pages;
class Providers
{
/**
* @param \XF\Pub\Controller\AbstractController $controller
* @param \XF\Mvc\Reply\AbstractReply &$reply
*/
public static function getData(
\XF\Pub\Controller\AbstractController $controller,
\XF\Mvc\Reply\AbstractReply &$reply
) {
if ($reply instanceof \XF\Mvc\Reply\View) {
$finder = \XF::finder('XF:Thread');
$thread = $finder->where('thread_id', 1)->fetchOne();
$firstPost = \XF::app()->finder('XF:Post')->where('post_id', $thread['first_post_id'])->fetchOne();
$viewParams = [
'title' => $thread['title'],
'message' => $firstPost['message']
];
// return $firstPost['message'];
$reply->setParam('providers', $viewParams);
}
}
}