Gets the canonical route for this page if its set. If provided it will use
that value, else if it's `true` it will use the default route.

@param null $var

@return bool|string
766326
public function routeCanonical($var = null)
    {
        if ($var !== null) {
            $this->routes['canonical'] = $var;
        }

        if (!empty($this->routes) && isset($this->routes['canonical'])) {
            return $this->routes['canonical'];
        }

        return $this->route();
    }
950724
public static function getCurrentRoute()
    {
        $current = null;
        $request = Request::current();
        $routeStr = $request->getRouteStr();
        $method = $request->getMethod();

        //Search for the route
        foreach (self::$routes as $route) {
            //Check the method
            if (!in_array($method, $route['methods'])) {
                continue;
            }

            //Check number of slashes
            if (
                substr_count($route['route'], '/')
                != substr_count($routeStr, '/')
            ) {
                continue;
            }

            //Checks the route string
            if (
                ParametrizedString
                    ::make($route['route'])
                    ->matches($routeStr)
            ) {
                $current = $route;
                break;
            }
        }

        return $current;
    }
1348992
static public function getRoute($uri = null)
    {
        $routes = self::$instance->routes;
        if($uri === null) {
            foreach($routes as $i => $route) {
                $routes[$i] = \array_diff_key($routes[$i], [3 => "xy", 4 => "xy", 5 => "xy", 6 => "xy", 7 => "xy", 8 => "xy"]);
                if( !is_string($routes[$i][2]) && is_object($routes[$i][2]) && is_callable($routes[$i][2]) && $routes[$i][2] instanceof \Closure) {
                    $routes[$i][2] = "Closure";
                }
            }
            return $routes;
        }
        else {
            foreach($routes as $i => $route) {
                if($route[1] === "/".ltrim($uri,"/")) {
                    return $route;
                }
            }
        }
    }
974964
public function getMagicVariableValue($variable)
    {
        $base_path_name = basename(realpath("."));

        switch ($variable) {
            case self::MAGIC_VAR_BASENAME:
                return $base_path_name;
                break;

            case self::MAGIC_VAR_UCFIRST_BASENAME:
                return ucfirst($base_path_name);
                break;

            case self::MAGIC_VAR_UPPER_CAMEL_CASE_BASENAME:
                return $this->toUpperCamelCase($base_path_name);
                break;

            case self::MAGIC_VAR_LOWER_CAMEL_CASE_BASENAME:
                return $this->toLowerCamelCase($base_path_name);
                break;
        }

        return null;
    }
959738
public static function get($variable, $default = null) {
    return isset(self::$apiConfig[$variable]) ? self::$apiConfig[$variable] : $default;
  }
67730
private function FindRouteMatch() {
        $route = new Route();
        $route->setDefaultUrl(Config::Init($this->app)->Get(\Puzzlout\Framework\Enums\AppSettingKeys::DefaultUrl));
        $this->getRoute($route, $this->url);
        return $route;
    }
400057
public function getRoute() {
        if ($this->route === null && $this->isIgnoredRoute() === false) {
            $this->route = $this->routes->matchRoute($this);
        }

        return $this->route;
    }
1221831
protected function getRootPageIdFromId($var)
    {
        if (is_numeric($var)) {
            // Passed variable is numeric
            $pageId = (int)$var;

            /** @var \TYPO3\CMS\Extbase\Object\ObjectManager $objectManager */
            $objectManager = Typo3GeneralUtility::makeInstance(
                'TYPO3\\CMS\\Extbase\\Object\\ObjectManager'
            );

            /** @var \TYPO3\CMS\Frontend\Page\PageRepository $pageRepo */
            $pageRepo = $objectManager->get('TYPO3\\CMS\\Frontend\\Page\\PageRepository');

            $page = $pageRepo->getPage($pageId);

            if (empty($page['is_siteroot'])) {
                throw new \RuntimeException('MetaSEO: Page with UID "' . $pageId . '" is no valid root page');
            }

            return $page['uid'];
        }

        // Passed variable is domain name
        $query = 'SELECT pid
                    FROM sys_domain
                   WHERE domainName = ' . DatabaseUtility::quote($var, 'sys_domain') . '
                     AND hidden = 0';
        $pid   = DatabaseUtility::getOne($query);

        if (empty($pid)) {

            return null;
        }

        return $pid;
    }
264222
public function orderDir($var = null)
    {
        //user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.6', E_USER_DEPRECATED);

        if ($var !== null) {
            $this->order_dir = $var;
        }

        if (empty($this->order_dir)) {
            $this->order_dir = 'asc';
        }

        return $this->order_dir;
    }
719547
public function modularTwig($var = null)
    {
        if ($var !== null) {
            $this->modular_twig = (bool)$var;
            if ($var) {
                $this->visible(false);
                // some routable logic
                if (empty($this->header->routable)) {
                    $this->routable = false;
                }
            }
        }

        return $this->modular_twig;
    }
666722
public function markdown($var = null)
    {
        $content = $this->content();

        if ($var !== null) {
            $content['markdown'] = (string) $var;
            $this->content($content);
        }

        return $content['markdown'];
    }
405482
public function route($route = null)
    {
        if (null === $route) {
            return $this->route;
        }
        $this->route = $route;

        return $this;
    }
768302
public function visible($var = null)
    {
        if ($var !== null) {
            $this->visible = (bool)$var;
        }

        if ($this->visible === null) {
            // Set item visibility in menu if folder is different from slug
            // eg folder = 01.Home and slug = Home
            if (preg_match(PAGE_ORDER_PREFIX_REGEX, $this->folder)) {
                $this->visible = true;
            } else {
                $this->visible = false;
            }
        }

        return $this->visible;
    }
6394
public function themeVarFunc($var, $default = null)
    {
        $header = $this->grav['page']->header();
        $header_classes = $header->{$var} ?? null;

        return $header_classes ?: $this->config->get('theme.' . $var, $default);
    }
334942
public function resolveRoute(): ?Route
    {
        $query = strtolower(rtrim($this->request->query->get('route'), '/'));

        switch(true) {
            case preg_match(self::WITH_IDENTIFIER_PATTERN, $query, $matches):
                $route = $this->detectRouteForWithIdentifierPattern($matches);

                break;
            case preg_match(self::NO_IDENTIFIER_PATTERN, $query, $matches):
                $route = $this->detectRouteForNoIdentifierPattern($matches);

                break;
            default:
                return null;
        }

        return $route;
    }
1079198
public function get(string $var)
    {
        if (!$this->mainNode) {
            return null;
        }

        $node = $this->mainNode->getLastByKey($var);
        if ($node === null) {
            return null;
        }

        return $node->getData();
    }
822976
public function post($var = null)
	{
		$this->id = 0;
		if (!empty($var)) {
			$routing = explode('/', $var);
			if (is_array($routing)) {
				$var = array_shift($routing);
				$this->id = empty($routing)
					? 0
					: array_shift($routing);
			} else {
				$var = $routing;
			}

			if ($this->checkAuth()) {
				// load action based off of naming conventions
				header('Content-Type: application/json');
				return $this->_autoaction($var, 'post');
			} else {
				return $this->getForbbiden($var);
			}
		} else {
			return $this->getNoop();
		}
	}