Find a template path

@param array  $info      The path information
@return array
768539
public function find(array $info)
    {
        //Get the package
        $package = $info['package'];

        //Get the domain
        $domain = $info['domain'];

        //Check if we are trying to find a template inside an application component
        if($path = $this->getObject('object.bootstrapper')->getApplicationPath($domain)) {
            $path = $path.'/com_'.strtolower($package);
        } else {
            $path = $this->getObject('object.bootstrapper')->getComponentPath($package).'/resources';
        }

        return array('com_' . $package => $path);
    }
1117487
protected function findTemplate()
    {
        if ($this->_path == false) {
            throw new PHPTAL_ConfigurationException('No template file specified');
        }

        // template source already defined
        if ($this->_source) {
            return;
        }

        if (!$this->resolvers && !$this->_repositories) {
            $this->_source = new PHPTAL_FileSource($this->_path);
        } else {
            foreach ($this->resolvers as $resolver) {
                $source = $resolver->resolve($this->_path);
                if ($source) {
                    $this->_source = $source;
                    return;
                }
            }

            $resolver = new PHPTAL_FileSourceResolver($this->_repositories);
            $this->_source = $resolver->resolve($this->_path);
        }

        if (!$this->_source) {
            throw new PHPTAL_IOException('Unable to locate template file '.$this->_path);
        }
    }
1113230
public function match($pathinfo)
    {
        $return = null;

        // Default (homepage) - index.html
        if (
            ('/' === $pathinfo) &&
            ($index_template = $this->resolver->resolveIndexTemplate())
        ) {
            $return = array(
                '_controller' => $this->controller,
                '_route' => $index_template->getRenderName(),
                'template' => $index_template,
            );
        }

        // 404 not found - 404.html

        if (!$return && ($nf_template = $this->resolver->resolveNotFoundTemplate())) {
            $return = array(
                '_controller' => $this->controller,
                '_route' => $nf_template->getRenderName(),
                'template' => $nf_template,
            );
        }

        // 404 not found - last resort
        if (!$return) {
            $return = array(
                '_controller' => $this->errorController,
                '_route' => '404',
            );
        }

        return($return);
    }
945157
private static function get_template_path( $template ) {
		$command_root  = Utils\phar_safe_path( dirname( __DIR__ ) );
		$template_path = "{$command_root}/templates/{$template}";

		if ( ! file_exists( $template_path ) ) {
			WP_CLI::error( "Couldn't find {$template}" );
		}

		return $template_path;
	}
502944
protected function parseLog($info)
    {
        $requestInfo = [
            'ip'     => $this->app['request']->ip(),
            'method' => $this->app['request']->method(),
            'host'   => $this->app['request']->host(),
            'uri'    => $this->app['request']->url(),
        ];

        if ($this->config['json']) {
            $info = $requestInfo + $info;
            return json_encode($info, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "\r\n";
        }

        array_unshift($info, "---------------------------------------------------------------\r\n[{$info['timestamp']}] {$requestInfo['ip']} {$requestInfo['method']} {$requestInfo['host']}{$requestInfo['uri']}");
        unset($info['timestamp']);

        return implode("\r\n", $info) . "\r\n";
    }
64879
public function find(array $info)
    {
        $locator = $this->getObject('manager')->getClassLoader()->getLocator('module');

        //Get the package
        $package = $info['package'];

        /*
         * Theme path
         */
        if(!empty($this->_override_paths))
        {
            //Remove the 'view' element from the path.
            $path = $info['path'];
            if(isset($path[0]) && $path[0] == 'view') {
                array_shift($path);
            }

            $path = count($path) ? implode('/', $path).'/' : '';

            foreach ($this->_override_paths as $override_path) {
                //If no type exists create a glob pattern
                if(!empty($info['type'])) {
                    $paths[] = $override_path.'/mod_'.$package.'/'.$path.$info['file'].'.'.$info['format'].'.'.$info['type'];
                } else {
                    $paths[] = $override_path.'/mod_'.$package.'/'.$path.$info['file'].'.'.$info['format'].'.*';
                }
            }
        }

        //Switch basepath
        if(!$locator->getNamespace(ucfirst($package))) {
            $basepath = $locator->getNamespace('\\');
        } else {
            $basepath = $locator->getNamespace(ucfirst($package));
        }

        $basepath .= '/mod_'.strtolower($package);

        $filepath   = (count($info['path']) ? implode('/', $info['path']).'/' : '').'tmpl/';

        //If no type exists create a glob pattern
        if(!empty($info['type'])) {
            $filepath  .= $info['file'].'.'.$info['format'].'.'.$info['type'];
        } else {
            $filepath  .= $info['file'].'.'.$info['format'].'.*';
        }

        $paths[] = $basepath.'/'.$filepath;

        foreach($paths as $path)
        {
            $results = glob($path);

            //Find the file in the directory
            if ($results)
            {
                foreach($results as $file)
                {
                    if($result = $this->realPath($file)) {
                        return $result;
                    }
                }
            }
        }

        return false;
    }
782807
private static function locate_template( $_view ) {

		if ( is_array( $_view ) ) {
			$_views = array();

			if ( isset( $_view[0] ) && false === strpos( $_view[0], '.php' ) ) {
				$_view_count = count( $_view );

				for ( $_view_x = $_view_count; 0 < $_view_x; $_view_x -- ) {
					$_view_v = array_slice( $_view, 0, $_view_x );

					$_views[] = implode( '-', $_view_v ) . '.php';
				}
			} else {
				$_views = $_view;
			}

			$_view = false;

			foreach ( $_views as $_view_check ) {
				$_view = self::locate_template( $_view_check );

				if ( ! empty( $_view ) ) {
					break;
				}
			}

			return $_view;
		}//end if

		// Keep it safe
		$_view = trim( str_replace( array( '../', '\\' ), array( '', '/' ), (string) $_view ) );

		if ( empty( $_view ) ) {
			return false;
		}

		$_real_view = realpath( $_view );

		if ( empty( $_real_view ) ) {
			$_real_view = $_view;
		}

		$located = false;

		// Is the view's file somewhere within the plugin directory tree?
		// Note: we explicitly whitelist PODS_DIR for the case of symlinks (see issue #2945)
		if ( false !== strpos( $_real_view, realpath( WP_PLUGIN_DIR ) ) || false !== strpos( $_real_view, realpath( WPMU_PLUGIN_DIR ) ) || false !== strpos( $_real_view, PODS_DIR ) ) {
			if ( file_exists( $_view ) ) {
				$located = $_view;
			} else {
				$located = apply_filters( 'pods_view_locate_template', $located, $_view );
			}
		} else {
			// The view's file is outside the plugin directory
			$_real_view = trim( $_real_view, '/' );

			if ( empty( $_real_view ) ) {
				return false;
			}

			// Allow views in the theme or child theme
			if ( file_exists( realpath( get_stylesheet_directory() . '/' . $_real_view ) ) ) {
				$located = realpath( get_stylesheet_directory() . '/' . $_real_view );
			} elseif ( file_exists( realpath( get_template_directory() . '/' . $_real_view ) ) ) {
				$located = realpath( get_template_directory() . '/' . $_real_view );
			}
		}//end if

		return $located;

	}
220526
private function get_node_path(file_info $fileinfo) {
        $encodedpath = base64_encode(json_encode($fileinfo->get_params()));
        return array(
            'path' => $encodedpath,
            'name' => $fileinfo->get_visible_name()
        );
    }
401644
public function find(array $info)
    {
        //Qualify partial templates.
        if(dirname($info['url']) === '.')
        {
            if(empty($info['base'])) {
                throw new RuntimeException('Cannot qualify partial template path');
            }

            $relative_path = dirname($info['base']);
        }
        else $relative_path = dirname($info['url']);

        $file   = pathinfo($info['url'], PATHINFO_FILENAME);
        $format = pathinfo($info['url'], PATHINFO_EXTENSION);

        $base_paths = array(JPATH_ROOT);

        if (!empty($this->_override_paths)) {
            foreach ($this->_override_paths as $override_path) {
                array_unshift($base_paths, $override_path);
            }
        }

        foreach ($base_paths as $base_path)
        {
            $path = $base_path.'/'.str_replace(parse_url($relative_path, PHP_URL_SCHEME).'://', '', $relative_path);

            // Remove /view from the end of the override path
            if (in_array($base_path, KObjectConfig::unbox($this->_override_paths)) && substr($path, strrpos($path, '/')) === '/view') {
                $path = substr($path, 0, -5);
            }

            if(!$result = $this->realPath($path.'/'.$file.'.'.$format))
            {
                $pattern = $path.'/'.$file.'.'.$format.'.*';
                $results = glob($pattern);

                //Try to find the file
                if ($results)
                {
                    foreach($results as $file)
                    {
                        if($result = $this->realPath($file)) {
                            return $result;
                        }
                    }
                }
            }
        }

        return $result;
    }
422014
private function getPaths($plugin): array
    {
        if ($plugin === null || !Plugin::loaded($plugin)) {
            return App::path('Template');
        }

        return App::path('Template', $plugin);
    }
754379
protected function getIpFromInfo($info)
    {
        $ip = \Piwik\Network\IP::fromStringIP($info['ip']);

        if ($ip instanceof \Piwik\Network\IPv6 && $ip->isMappedIPv4()) {
            return $ip->toIPv4String();
        } else {
            return $ip->toString();
        }
    }
1228307
public function getTemplateFile($template)
	{
	    if (!is_file($template)) {
	        $template = $this->getTemplatePath() . $this->_getRelativeTemplate($template) . $this->getSuffix();
	    }
	    
	    return $template;
	}
502877
protected function resolveTemplate($template)
    {
        if (!$this->pathCache[$template]) {

            foreach (array_reverse($this->templateDirs) as $dir) {
                $path = $dir . DIRECTORY_SEPARATOR . $template .'.'. $this->getFileExtension();
                if (is_readable($path)) {
                    $this->pathCache[$template] = $path;
                    break;
                }
            }

        }

        return $this->pathCache[$template];
    }
163778
public function getTemplateFilePath($templateName)
    {
        $templateList = array_merge(
            [ $this ],
            $this->getParentList()
        );

        /** @var TemplateDefinition $templateDefinition */
        foreach ($templateList as $templateDefinition) {
            $templateFilePath = sprintf(
                '%s%s/%s',
                THELIA_TEMPLATE_DIR,
                $templateDefinition->getPath(),
                $templateName
            );

            if (file_exists($templateFilePath)) {
                return $templateFilePath;
            }
        }

        throw new TemplateException("Template file not found: $templateName");
    }
470751
protected function findTemplate($name)
    {
        try {
            return parent::findTemplate($name);
        } catch (\Twig_Error_Loader $e) {
            $namespace = self::MAIN_NAMESPACE;

            if (is_readable($name)) {
                return $name;
            }

            throw new \Twig_Error_Loader(sprintf(
                'Unable to find template "%s" (looked into: %s).',
                $name,
                implode(', ', $this->paths[$namespace])
            ));
        }
    }
1305198
public function getTemplateRootPaths()
    {
        if ($this->templateRootPaths !== []) {
            return $this->templateRootPaths;
        }

        if ($this->templateRootPathPattern === null) {
            return [];
        }

        $templateRootPath = $this->templateRootPathPattern;
        if (isset($this->patternReplacementVariables['packageKey'])) {
            $templateRootPath = str_replace('@packageResourcesPath', 'resource://' . $this->patternReplacementVariables['packageKey'], $templateRootPath);
        }

        return [$templateRootPath];
    }
289352
protected function _parseTableInfo($info)
    {
        $table = new AnDatabaseSchemaTable;
        $table->name        = $info->Name;
        $table->engine      = $info->Engine;
        $table->type        = $info->Comment == 'VIEW' ? 'VIEW' : 'BASE';
        $table->length      = $info->Data_length;
        $table->autoinc     = $info->Auto_increment;
        $table->collation   = $info->Collation;
        $table->behaviors   = array();
        $table->description = $info->Comment != 'VIEW' ? $info->Comment : '';

        return $table;
    }