Get a page ancestor.

@param  string $route The relative URL of the page
@param  string $path The relative path of the ancestor folder

@return PageInterface|null
779931
public function ancestor($route, $path = null)
    {
        if ($path !== null) {
            $page = $this->dispatch($route, true);

            if ($page && $page->path() === $path) {
                return $page;
            }

            $parent = $page ? $page->parent() : null;
            if ($parent && !$parent->root()) {
                return $this->ancestor($parent->route(), $path);
            }
        }

        return null;
    }
377354
private function resolveController($route, $path)
    {
        $pathComponents = explode('/', $path);
        $baseClassPath = $this->config->getClassPath($route);

        $classObject = null;
        $aliases = $this->config->getAliases($route);

        $class = $baseClassPath;
        $classAlias = '';

        $controllerFactory = $this->config->getControllerFactory();
        $routeConfig = [];

        $routes = $this->config->getRoutes();
        if (is_array($routes) && isset($routes[$route]['config'])) {
            $routeConfig = $routes[$route]['config'];
        }

        while ($pathComponents) {
            $pathComponent = array_shift($pathComponents);

            $class = $class.'\\'.ucfirst($pathComponent);
            $classAlias .= ucfirst($pathComponent);

            // check for an alias first
            if (isset($aliases[strtolower($classAlias)])) {
                $aliasClass = $baseClassPath.'\\'.$aliases[strtolower($classAlias)];

                if (class_exists($aliasClass)) {
                    $classObject = $controllerFactory($aliasClass, $routeConfig);
                    break;
                }
            }

            if (class_exists($class)) {
                $classObject = $controllerFactory($class, $routeConfig);

                if (!$classObject) {
                    $classObject = new $class();
                    break;
                }

                break;
            }

            $classAlias .= '/';
        }

        if (!$classObject) {
            throw new \Exception('API: No controller found for the requested end point. ');
        }

        // any path left over becomes args
        $pathArgs = $pathComponents;

        return [$classObject, array_shift($pathArgs), $pathArgs];
    }
114213
public static function getByPath($path, $version = 'RECENT')
    {
        $path = rtrim($path, '/'); // if the path ends in a / remove it.

        $cID = CacheLocal::getEntry('page_id_from_path', $path);
        if ($cID == false) {
            $db = Database::connection();
            $cID = $db->fetchColumn('select cID from PagePaths where cPath = ?', array($path));
            CacheLocal::set('page_id_from_path', $path, $cID);
        }

        return static::getByID($cID, $version);
    }
434780
public function routePage($path)
    {
        $url = URL::findByLocation($path);

        if ($url) {
            $page = $url->getPage();

            if (!$page || $page->isDeleted()) {
                // The url is in use but doesn't have a page.
                // The page must have been deleted.
                throw new GoneHttpException();
            }

            if (Editor::isDisabled() && !$page->isVisible()) {
                throw new NotFoundHttpException();
            }

            if (!$page->url()->matches($path)) {
                return redirect((string) $page->url(), 301);
            }

            $this->setActivePage($page);

            return;
        }

        throw new NotFoundHttpException();
    }
509248
protected function getRouteInformation(Route $route)
    {
        if ($route->getName()) {
            return [
                'uri'    => $route->uri(),
                'name'   => $route->getName(),
                'before' => $this->getBeforeFilters($route),
            ];
        }

        return null;
    }
516169
protected function getRouteResource($route)
	{
		if (!config('openapischemas.resource_tag')) {
			$this->parentCommand->error('The "resource_tag" value in your apischemas.php configuration file must defined.');
			exit();
		}
		$routeAction = $route->getAction();
		list($class, $method) = explode('@', $routeAction['uses']);
		$reflection = new ReflectionClass($class);

		$comment = $reflection->getDocComment();
		if ($comment) {
			$docBlock = $this->docBlockFactory->create($comment);
			foreach ($docBlock->getTags() as $tag) {
				if ($tag->getName() === config('openapischemas.resource_tag')) {
					return $tag->getDescription()->render();
				}
			}
		}

		return null;
	}
255417
public function get($path)
    {
        $return = null;
        $path = \preg_split('#[./]#', $path);
        $depth = 0;
        while ($path) {
            $key = \array_shift($path);
            if ($depth == 0) {
                if ($key == 'currentPage') {
                    $return = $this->data['pages'][ $this->data['i'] ];
                } elseif ($key == 'nextI') {
                    foreach ($this->data['pages'] as $i => $page) {
                        if (!$page['completed']) {
                            return $i;
                        }
                    }
                // } elseif ($key == 'submitted') {
                    // return $this->data['submitted'];
                } elseif (isset($this->data[$key])) {
                    $return = $this->data[$key];
                } elseif (isset($this->data['persist'][$key])) {
                    $return = $this->data['persist'][$key];
                } else {
                    return null;
                }
            } elseif (isset($return[$key])) {
                $return = $return[$key];
            } else {
                return null;
            }
            $depth++;
        }
        return $return;
    }
1260318
public function getPage(Environment $twig, $path, $context = [])
    {
        $page = null;

        $path = Page::generateRelativePath($path);
        $template = $twig->load($path);
        $page = new Page($template, $context, $this->userAgentEnabled);

        if ($this->translationEnabled) {
            $page->link = $this->routeResolver->resolveRouteByFile($page->path, $this->request->getLocale());
        }

        return $page;
    }
425031
protected function getLinks($route,array $parameters = array()){
        $links = array();
        if($route != null){
            $baseParams = $_GET;
            unset($baseParams["page"]);
            $parameters = array_merge($parameters,$baseParams);
            $links['first']['href'] = $this->generateUrl($route, array_merge($parameters, array('page' => 1)));
            $links['self']['href'] = $this->generateUrl($route, array_merge($parameters, array('page' => $this->getCurrentPage())));
            $links['last']['href'] = $this->generateUrl($route, array_merge($parameters, array('page' => $this->getNbPages())));
            if($this->hasPreviousPage()){
                $links['previous']['href'] = $this->generateUrl($route, array_merge($parameters, array('page' => $this->getPreviousPage())));
            }
            if($this->hasNextPage()){
                $links['next']['href'] = $this->generateUrl($route, array_merge($parameters, array('page' => $this->getNextPage())));
            }
        }
        return $links;
    }
408216
public function ancestor($lookup = null)
    {
        /** @var Pages $pages */
        $pages = Grav::instance()['pages'];

        return $pages->ancestor($this->route, $lookup);
    }
1344254
public function iAmOnPage($route)
    {
        $parameters = [];
        $requestBody = $this->dataContext->getRequestBody();
        if($requestBody != null){
            $parameters = $requestBody;
        }
        $this->getSession()->visit($this->generatePageUrl($route,$parameters));
        if($this->isOpenBrowser()){
            $this->getSession()->wait(2000);
        }
    }
270689
public function callRouteBefore($route, $request)
	{
		$response = $this->callPatternFilters($route, $request);

		return $response ?: $this->callAttachedBefores($route, $request);
	}
44511
public function getPage($url)
    {
        $pages = $this->getPages();
        $url = $this->normalizeUrl($url);

        if (!isset($pages[$url])) {
            return null;
        }


        $record = $pages[$url];

        foreach ($this->getEntities() as $entity) {
            if (strpos($record['filepath'], $entity->getPath()) !== false) {
                $page =  Injector::inst()->create(
                    $record['type'],
                    $entity,
                    $record['basename'],
                    $record['filepath']
                );

                return $page;
            }
        }
    }
912242
private function getRouteName($route = null)
    {
        return null === $route ? $this->request->attributes->get('_route') : $route;
    }
471188
protected function getContent($path)
    {
        if (null === self::$root) {
            return null;
        }

        if (self::$root->getName() === $path) {
            return self::$root;
        }

        if (self::$root->hasChild($path) === true) {
            return self::$root->getChild($path);
        }

        return null;
    }
342693
protected function getRouteControllerDocBlock($route)
	{
		$routeAction = $route->getAction();
		list($class, $method) = explode('@', $routeAction['uses']);

		$reflectionClass = new ReflectionClass($class);

		$comment = $reflectionClass->getDocComment();

		if ($comment) {
			return($this->docBlockFactory->create($comment));
		}

		return null;
	}
1343533
public function getController($route = null)
		{
		    $router = $this->init($route == null)->router;
			return $route
                ? $router->getController($route)
                : $router->getControllers();
		}