Locate the template

@param  string $url   The template url
@return string|false The real template path or FALSE if the template could not be found
978732
public function locate($url)
    {
        if(!isset($this->_locations[$url]))
        {
            $layout = $this->getLayout($url);

            $info = array(
                'url'      => $url,
                'domain'   => $layout->getDomain(),
                'package'  => $layout->getPackage(),
                'path'     => $layout->getPath(),
            );

            $info += $this->parseIdentifier($url);

            $this->_locations[$url] = $this->find($info);
        }

        return $this->_locations[$url];
    }
514654
protected static function parseUrl($url)
    {
        $url_parts = Utils::multibyteParseUrl($url);

        if (isset($url_parts['scheme'])) {
            /** @var UniformResourceLocator $locator */
            $locator = Grav::instance()['locator'];

            // Special handling for the streams.
            if ($locator->schemeExists($url_parts['scheme'])) {
                if (isset($url_parts['host'])) {
                    // Merge host and path into a path.
                    $url_parts['path'] = $url_parts['host'] . (isset($url_parts['path']) ? '/' . $url_parts['path'] : '');
                    unset($url_parts['host']);
                }

                $url_parts['stream'] = true;
            }
        }

        return $url_parts;
    }
265747
public function find($url)
    {
        $catalogue = $this->getCatalogue();

        if ($catalogue instanceof ComActivitiesActivityTranslatorCatalogueInterface)
        {
            // Locate files using fallback locale
            $locale  = $this->getLocaleFallback();
            $locator = $this->getObject('translator.locator.factory')->createLocator($url);
            $result  = $locator->setLocale($locale)->locate($url, $locale);
        }
        else $result = $this->getDelegate()->find($url);

        return $result;
    }
1259967
private function getRequestPath($url) {
		$urlParts = parse_url($url);
		$path = $urlParts['path'];
		if (isset($urlParts['query'])) {
			$path .= '?' . $urlParts['query'];
		}
		if (isset($urlParts['fragment'])) {
			$path .= '#' . $urlParts['fragment'];
		}
		return $path;
	}
171208
protected function doRouteMatching($url)
    {
        $matches = array();
        foreach ($this->route_definitions as $name => $route) {
            if (preg_match($route['regex'], $url, $matches)) {
                $matches[0] = $name;
                return $matches;
            }
        }
        return false;
    }
300330
protected function locate_template() : string {

		if ( isset( $this->template ) ) {
			return $this->template;
		}

		$templates = [];

		if ( ! empty( $this->name ) ) {
			$templates[] = "{$this->args['dir']}/{$this->slug}-{$this->name}.php";
		}

		$templates[] = "{$this->args['dir']}/{$this->slug}.php";

		$this->template = locate_template( $templates );

		if ( 0 !== validate_file( $this->template ) ) {
			$this->template = '';
		}
		return $this->template;

	}
20084
public static function base($url) {
        if (preg_match('#^(/|(ht|f)tps?://).+#', $url)) {
            return $url;
        }
        $url = preg_replace('#/?index\.html?$#', '', $url);

        return WWWROOT_DIR . $url;
    }
397053
private function findTemplate($template)
    {
        $logicalName = (string) $template;

        if (isset($this->cache[$logicalName])) {
            return $this->cache[$logicalName];
        }

        $template = $this->templateNameParser->parse($template);
        $file = $this->templateLocator->locate($template);

        return $this->cache[$logicalName] = $file;
    }
1007236
private function locateTemplate()
    {
        foreach ($this->bundles as $bundleName) {
            $templateName = "{$bundleName}:{$this->templatePath}";

            if ($this->engine->exists($templateName)) {
                return $templateName;
            }
        }

        throw new RuntimeException(sprintf(
            'Template "%s" not found',
            $this->templatePath
        ));
    }
454381
private function getLocalPath($url)
	{
		$basePath = dirname(Yii::app()->request->scriptFile) . DIRECTORY_SEPARATOR;
		$baseUrl = Yii::app()->request->baseUrl . '/';
		if (!strncmp($url, $baseUrl, strlen($baseUrl)))
		{
			$url = $basePath . substr($url, strlen($baseUrl));
			return $url;
		}
		return false;
	}
1355678
protected function checkUrl($url)
    {
        if ($this->fullName) {
            $pos = strpos($this->fullName, '<');

            if (false !== $pos) {
                $str = substr($this->fullName, 0, $pos);
            } else {
                $str = $this->fullName;
            }

            if ($str && 0 !== stripos(str_replace('|', '/', $url), $str)) {
                return false;
            }
        }

        return true;
    }
422970
private function getHostFromUrl($url)
    {
        if (strpos($url, '//')) {
            $url = substr($url, strpos($url, '//') + 2);
        }
        if (($p = strpos($url, '/')) !== false) {
            $url = substr($url, 0, $p);
        }
        return $url;
    }
74209
public function exists($template)
    {
        if (DIRECTORY_SEPARATOR === '\\' && strpos($template, '\\') !== false) {
            $template = str_replace('\\', '/', $template);
        }

        if (strpos($template, '/') === false) {
            $template = dirname(end($this->_context->templates)) . '/' . $template;
        }

        $template = $template[0] === '@' ? $this->alias->resolve($template) : $template;

        if (isset($this->_files[$template])) {
            return true;
        }

        foreach ($this->_engines as $extension => $_) {
            if (is_file($file = $template . $extension)) {
                if (PHP_EOL !== "\n") {
                    $realPath = strtr(realpath($file), '\\', '/');
                    if ($file !== $realPath) {
                        trigger_error("File name ($realPath) case mismatch for $file", E_USER_ERROR);
                    }
                }
                $this->_files[$template] = [$file, $extension];
                return $file;
            }
        }

        return false;
    }
1184781
protected function findProvider($url)
    {
        foreach ($this->providers as $regex => $provider) {
            if (preg_match("#^$regex.*$#i", $url)) {
                return $provider;
            }
        }

        return false;
    }
601731
public function getTemplatePath($template)
    {
        $reportname = preg_replace("/.xml/", "", $this->xmloutfile . '_' . $template);

        // Some calling frameworks require output to be returned
        // for rendering inside web pages .. in this case
        // return_output_to_caller will be set to true

        if (preg_match("/$reportname/", ReporticoUtility::findBestLocationInIncludePath("templates/" . $this->getTheme() . $reportname))) {
            $template = $reportname;
        }

        if (preg_match("/$reportname/", ReporticoUtility::findBestLocationInIncludePath("templates/" . $reportname))) {
            $template = $reportname;
        } else if ($this->user_template) {
            $template = $this->user_template . "_$template";
        }

        return $template;
        //return $this->getTheme() . '/' . $template;
    }
271392
public static function get_server_location( $url ) {
		// if we're already an absolute dir, just return.
		if ( 0 === strpos($url, ABSPATH) ) {
			return $url;
		}
		// otherwise, analyze URL then build mapping path
		$au = self::analyze_url($url);
		$result = self::_get_file_path($au['base'], $au['subdir'], $au['basename']);
		return $result;
	}
160275
protected function _locate($url)
    {
        //Locate the template
        if (!$file = $this->getObject('template.locator.factory')->locate($url)) {
            throw new InvalidArgumentException(sprintf('The template "%s" cannot be located.', $url));
        }

        return $file;
    }