XF 2.2 Is the public type in router necessary?

LPH

Well-known member
I'm curious if the public type in router is necessary. The type was missing in code I wrote a few years ago but the code still appeared to work. Hovering over the router() with PhpStorm shows null | string.

I went ahead and added the public type but am really curious what it does since 'admin' is the other type.

PHP:
XF::app()->router('public')->buildLink( 'canonical:threads', $thread )
 
It defaults to the router for the current app context, but if you're building links to public routes it's a good idea to be explicit about it.

I went ahead and added the public type but am really curious what it does since 'admin' is the other type.
Passing admin instead would build control panel links, for example.
 
  • Like
Reactions: LPH
Back
Top Bottom