public function afterInitialization() { parent::afterInitialization(); $this->menuCreator(); $this->container->dispatcher->addListener('app.beforeRun', function ($event) { PageRouteCollection::register($event->getApp()); }, 2000); }
public function registerRoute() { $sections = Sections::getAllGlobalActive()->keyBy('id')->toArray(); if (empty($sections)) { return; } foreach ($sections as $section) { $url = array_filter(explode(\App\Models\Sections::PATH_DELIMITER, $section['path'])); foreach ($url as &$id) { $id = $sections[$id]['code']; } $url[-1] = ''; $url[] = $section['code']; ksort($url); $url = implode(\App\Models\Sections::PATH_DELIMITER, $url); PageRouteCollection::add(new PageResource($url . '/', 'sectionAction', 's' . $section['id'])); PageRouteCollection::add(new PageResource($url . '/{pageCode}', 'detailAction', 'sp' . $section['id'])); } }