I cannot find any documentation that specifies how to link to controller actions which return a rendered template in CP.
Let's say I have a plugin called waffles
and my namespace is Very\Waffles
. I have a controller named SyrupController
and it's residing in Controllers
directory (note the capitalized directory name). So the namespace for it would be Very\Waffles\Controllers
.
An action actionPour()
- how can I register a route that would call this action if I land on the /admin/waffles
URL?
I've walked through the steps with a debugger and It's trying to check if a SyrupController
exists but how can it, if only Very\Waffles\Controllers\SyrupController
exists? Thus it fails to register that route and fails.
Any help much appreciated!
Here's some code:
Event::on(
UrlManager::class,
UrlManager::EVENT_REGISTER_CP_URL_RULES,
function (RegisterUrlRulesEvent $event) {
$event->rules['waffles'] = 'waffles/syrup/pour';
}
);
It shouldn't be possible to link to a controller by using this string, so I'm guessing an array that specifies the SyrupController::class
, but there's no documentation about it.
Thanks!