Quantcast
Channel: phpBB.com
Viewing all articles
Browse latest Browse all 2802

Extension Writers Discussion • Re: Make current user ID globally available in templates

$
0
0
Ok cool. phpBB just lost my post. Better post it again...

At the moment I have this in main-listener:

Code:

namespace gumboots\gbcurrentuser\event;/** * @ignore */use Symfony\Component\EventDispatcher\EventSubscriberInterface;/** * Gumboots Current User Event listener. */class main_listener implements EventSubscriberInterface{/* @var user */protected $user;/** @var \phpbb\template\template */protected $template;public function __construct(\phpbb\user\user $user, \phpbb\template\template $template){$this->config = $user;$this->template = $template;}static public function getSubscribedEvents(){return array('core.page_header'=> 'page_header',);}public function page_header($event){$this->template->assign_vars(array('GB_CURRENT_USER_ID' => $this->user->data['user_id'],));}}
That gives an error on this line:

Code:

public function __construct(\phpbb\user\user $user, \phpbb\template\template $template)

Code:

Fatal error: Uncaught TypeError: Argument 1 passed to gumboots\gbcurrentuser\event\main_listener::__construct() must be an instance of phpbb\user\user, instance of phpbb\user given in ...
Of course if I'd stuck to the core hack, which was already working, there would be no issues. I've already spent enough time on this to do the manual edit in at least 10 upgrades. :lol:

Statistics: Posted by Gumboots — Mon Apr 21, 2025 5:45 am



Viewing all articles
Browse latest Browse all 2802

Trending Articles