/** * Search routes for those containing the prismic bookmark parameter in defaults * * @param array $routes Router config array * @param string $parent to help work out the fully qualified route name when called recursively * @return array */ protected function findBookmarkedRoutes(array $routes, $parent = '') { $searchParam = $this->routerOptions->getBookmarkParam(); $out = array(); foreach ($routes as $name => $route) { $fqrn = trim($parent . '/' . $name, '/'); $bookmark = isset($route['options']['defaults'][$searchParam]) ? $route['options']['defaults'][$searchParam] : NULL; if (!empty($bookmark)) { $out[$bookmark] = $fqrn; } if (isset($route['child_routes']) && count($route['child_routes'])) { $out = array_merge($out, $this->findBookmarkedRoutes($route['child_routes'], $name)); } } return $out; }
/** * Return the bookmark referenced in the route matched for the current request * @return string|NULL */ public function getBookmarkNameFromRoute() { $params = $this->getController()->plugin('params'); $search = $this->routerOptions->getBookmarkParam(); return $params->fromRoute($search); }