/** * load * * @param unknown $resource * @param mixed $type * * @return array */ public function load($resource, $type = null) { if (true === $this->loaded) { throw new \RuntimeException('Do not add the admin routes loader twice'); } $routes = new RouteCollection(); $adminRoutes = $this->core->getRoutes(); $adminResources = $this->core->getAdmins(); // Foreach admin resource, and each generic page it requires: loop and create a route foreach ($adminRoutes as $slug => $adminRoute) { foreach ($adminRoute as $action) { // prepare a new route $path = $action['path']; $defaults = array('_controller' => $adminResources[$slug]['service'] . ':' . $action['action']); $route = new Route($path, $defaults, $action['requirements']); $routeName = $action['route']; // add the new route to the route collection $routes->add($routeName, $route); } } $this->loaded = true; return $routes; }
/** * @param Request $request * @param Response $response * @param \Exception|null $exception */ public function collect(Request $request, Response $response, \Exception $exception = null) { $this->data = array('adminsTotal' => count($this->core->getAdmins()), 'admins' => $this->core->getAdmins(), 'routes' => $this->core->getRoutes(), 'currentAdminService' => $this->core->getCurrentAdmin()['service'], 'currentAdminSlug' => $this->core->getCurrentSlug(), 'currentEntityClass' => $this->core->getCurrentEntityClass(), 'currentAction' => $this->core->getCurrentAction()); }