Translates view identifier to path

@param string $name

@return string
@throws ViewException
188766
protected function translate($name)
    {
        preg_match_all('/^(?P<bundle>[^:]+):(?P<directory>[^:]*:)?(?P<file>.+)$/', $name, $matches, \PREG_SET_ORDER);

        foreach (['bundle', 'file'] as $offset) {
            if (empty($matches[0][$offset])) {
                throw new ViewException(sprintf('Invalid or missing "%s" node in view filename "%s"', $offset, $name));
            }
        }

        $placeholders = [
            '{bundle}' => $matches[0]['bundle'],
            '{file}' => $matches[0]['file'],
            '{directory}' => isset($matches[0]['directory']) ? str_replace(':', '\\', $matches[0]['directory']) : null,
        ];

        $file = strtr($this->pattern, $placeholders);
        $file = str_replace(array('\\', '_', '//'), '/', $file);

        return $file;
    }
589918
public static function loadCoreView(string $name) {
      $base = __DIR__ . '/../../Views/';
      if (!file_exists($base . $name . '.view')) {
        throw new \Nuki\Exceptions\Base('The view file "' . $name . '" does not exist.');
      }
      
      return file_get_contents($base . $name . '.view');
    }
673695
public function resolver($name = null)
    {
        if (null === $this->__templateResolver) {
            $this->setResolver(new TemplatePathStack());
        }

        if (null !== $name) {
        	$viewPath = $this->__templateResolver->resolve($name, $this);
        	//echo $viewPath. "<br>";
            return $this->__templateResolver->resolve($name, $this);
        }

        return $this->__templateResolver;
    }
568748
private function getViewFilePath($name, $extension = 'html')
    {
        // Check view file
        $viewFile = $this->getViewFile($name, $extension);
        if (!file_exists($viewFile)) {
            // Check for view folder
            $viewBaseName = $this->getViewFolder($name) . DIRECTORY_SEPARATOR . 'view';

            // Select the view file
            $viewFile = (file_exists($viewBaseName . '.php') ? $viewBaseName . '.php' : $viewBaseName . '.html');
            $viewFile = (file_exists($viewFile) ? $viewFile : null);
        }

        // Check if the file is executable (php)
        if (preg_match('/\.php$/', $viewFile)) {
            $this->executable = true;
        }

        return $viewFile;
    }
1244413
protected static function view(string $name, array $vars): string
    {
        static $path = null;
        $path        = $path ?? (
                self::$config['views'] ?? realpath(dirname(__DIR__ . '/../../../application/') . 'views/mail')
            );

        return (new PhpTemplate("$path/$name.php"))
            ->setVars($vars)
            ->compile()
            ;
    }
402552
public function getRoutePath($name)
    {
        if (null !== $this->get($name)) {
            return $this->get($name)->getPath();
        }

        return null;
    }
1172649
public function find($name)
    {

        if (strpos($name, '::') !== false) {
            return $this->findNamedPathView($name);
        }
        return $this->findInPaths($name, $this->paths);
    }
1232830
protected function translateName($name)
    {
        if ($name === '/index.php') {
            return '';
        }

        $name = ltrim($name, '/');
        $name = rtrim($name, '/');

        return preg_replace('/[^A-Za-z0-9\-_]/', '', strtr($name, [
            '/' => '_',
            '.md' => '',
        ]));
    }
645598
private function getTemplatePath($name)
    {
        if (strpos($name, '::') !== false) {
            $parts = explode('::', $name);
            $ns = array_shift($parts);

            if (isset($this->manager->namespaces[$ns])) {
                $path = $this->manager->namespaces[$ns] . '/' . join('/', $parts) . $this->manager->filesExtension;
            } else {
                throw new LogicException(sprintf("Template namespace '%s::' not defined", $ns));
            }
        } else {
            $path = $this->manager->defaultDirectory . '/' . $name . $this->manager->filesExtension;
        }

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

        throw new LogicException(sprintf("Template file '%s' not found", $path));
    }
656146
protected function findViewFile(string $name): string {
    if (!mb_strlen($name)) throw new InvalidArgumentException('The view name is empty.');

    $controller = \Yii::$app->controller;
    if (mb_substr($name, 0, 2) == '//')
      $file = \Yii::$app->viewPath.DIRECTORY_SEPARATOR.ltrim($name, '/');
    else if ($name[0] == '/') {
      if (!$controller) throw new InvalidCallException("Unable to locate the view '$name': no active controller.");
      $file = $controller->module->viewPath.DIRECTORY_SEPARATOR.ltrim($name, '/');
    }
    else {
      $viewPath = $controller ? $controller->viewPath : \Yii::$app->viewPath;
      $file = \Yii::getAlias("$viewPath/$name");
    }

    $view = \Yii::$app->view;
    if ($view && $view->theme) $file = $view->theme->applyTo($file);
    if (!mb_strlen(pathinfo($file, PATHINFO_EXTENSION))) $file .= '.'.($view ? $view->defaultExtension : 'mustache');
    return $file;
  }
1322993
public function getPathSegment($name)
    {
        if (!isset($this->pathSegments[$name])) {
            throw new \InvalidArgumentException(
                sprintf(
                    'Unknown path segment "%s". Known path segments: "%s"',
                    $name,
                    implode('", "', array_keys($this->pathSegments))
                )
            );
        }

        return $this->pathSegments[$name];
    }
731836
public function find($name)
	{
		if (isset($this->views[$name])) return $this->views[$name];

		if (strpos($name, '::') !== false)
		{
			return $this->views[$name] = $this->findNamedPathView($name);
		}

		return $this->views[$name] = $this->findInPaths($name, $this->paths);
	}
359597
protected function _getLayoutPartialPath($name)
    {
        list($plugin, $name) = $this->pluginSplit($name);

        $paths       = $this->_paths($plugin);
        $layoutPaths = $this->_getSubPaths('Layout' . DS . 'Partial');

        foreach ($paths as $path) {
            foreach ($layoutPaths as $layoutPath) {
                $partial = $path . $layoutPath . DS . $name . $this->_ext;
                if (FS::isFile($partial)) {
                    return $partial;
                }
            }
        }

        return false;
    }
1270439
protected function getPath($name)
    {
        $name = str_replace_first($this->laravel->getNamespace(), '', $name);

        return sprintf('%s/%s/%s/%s',
            $this->laravel['path'],
            str_replace('\\', '/', $name),
            $this->convention->providersFolder(),
            'ModuleServiceProvider.php'
        );
    }
861122
public function getApplicationPath($name)
    {
        $result = null;

        if(isset($this->_applications[$name])) {
            $result = $this->_applications[$name];
        }

        return $result;
    }
31799
private function pathId($name)
    {
        $parts = $this->splitName($name);
        if ($parts[0] === '') {
            return null;
        }

        return end($parts);
    }
51163
function load($name): string {
    if (!isset($this->views[$name])) {
      $cacheKey = [__CLASS__, $name];
      $viewRenderer = $this->viewRenderer;

      /** @var \yii\caching\Cache $cache */
      $cache = $viewRenderer->cache;
      if ($viewRenderer->enableCaching && $cache->exists($cacheKey))
        $output = $cache->get($cacheKey);
      else {
        $path = FileHelper::localize($this->findViewFile($name));
        if (!is_file($path)) throw new InvalidCallException("The view file '$path' does not exist.");

        $output = @file_get_contents($path);
        if ($viewRenderer->enableCaching) $cache->set($cacheKey, $output, $viewRenderer->cachingDuration);
      }

      $this->views[$name] = $output;
    }

    return $this->views[$name];
  }