/** * */ public function identity($prop = null) { if (!$this->authService->hasIdentity()) { return; } $identity = $this->authService->getIdentity(); if (null !== $prop) { return $identity->{$prop}; } return $identity; }
protected function registerRoute($route, $name) { $path = $route['path']; if (isset($route['methods'])) { $methods = (array) $route['methods']; } elseif (isset($route['method'])) { $methods = (array) $route['method']; } else { $methods = ['GET']; } $options = []; if (isset($route['params'])) { $options['params'] = $route['params']; } if (isset($route['constructor_params'])) { $options['constructor_params'] = $route['constructor_params']; } // it is possible to provide a subarray to 'methods', which means the same // route will serve multiple HTTP methods, but with different controllers // for each method. if that is the case, iterate through the methods and // add the route for each of them. if (array_filter(array_keys($methods), 'is_string')) { foreach ($methods as $method => $controller) { $this->router->addRoute([$method], $path, $controller, $name, $options); // only set the name for the first route added. the URLs will be // identical so it doesn't matter for URL generation. $name = null; } } else { // only a single method is being mapped $controller = isset($route['controller']) ? $route['controller'] : $route['handler']; $this->router->addRoute($methods, $path, $controller, $name, $options); } }
/** * Remove this handler. */ public function cancel() { if (isset($this->pointer) && isset($this->router) && !$this->cancelled) { $this->router->removeHandler($this->pointer[0], $this->pointer[1]); $this->cancelled = true; } }
/** * Get the relative URI of this navigation item using the given * {@see RouterInterface} object. * * @param RouterInterface $router Used to generate the URI. * @param string $routeID The ID of the route. * @return string * */ public function getRelativeURI(RouterInterface $router, $routeID) { return $router->getURI($routeID, $this->routingArgs, FALSE); }
/** * @param RouterInterface $router */ public function add(RouterInterface $router) { $router->initialize(); }
/** * {@inheritdoc} */ public function any($path, $handler) { return $this->router->any($this->prefix . $path, $handler); }