. // }}} namespace Plugin\PollPlugin; use App\Core\Event; use App\Core\Module; use Plugin\PollPlugin\Entity\Poll; const ID_FMT = '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'; class PollPlugin extends Module { /** * Map URLs to actions * * @param URLMapper $m path-to-action mapper * @param mixed $r * * @return bool hook value; true means continue processing, false means stop. */ /* public function onRouterInitialized(URLMapper $m) { $m->connect('main/poll/new', ['action' => 'newpoll']); $m->connect('main/poll/:id', ['action' => 'showpoll'], ['id' => '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}']); $m->connect('main/poll/response/:id', ['action' => 'showpollresponse'], ['id' => '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}']); $m->connect('main/poll/:id/respond', ['action' => 'respondpoll'], ['id' => '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}']); $m->connect('settings/poll', ['action' => 'pollsettings']); return true; } */ public function onAddRoute($r) { $r->connect('newpoll', 'main/poll/new', [Controller\NewPoll::class, 'newpoll']); $r->connect('showpoll', 'main/poll/{id<' . ID_FMT . '>}' , [Controller\ShowPoll::class, 'showpoll']); return Event::next; } }