Returns array containing fixtures templates file names. You can specify what files to find
by the given parameter.
@param array $templatesNames template file names to search. If empty then all files will be searched.
@return array
@since 2.0.4
513749
protected function findTemplatesFiles(array $templatesNames = [])
    {
        $findAll = ($templatesNames == []);

        if ($findAll) {
            $files = FileHelper::findFiles(Yii::getAlias($this->templatePath), ['only' => ['*.php']]);
        } else {
            $filesToSearch = [];

            foreach ($templatesNames as $fileName) {
                $filesToSearch[] = $fileName . '.php';
            }

            $files = FileHelper::findFiles(Yii::getAlias($this->templatePath), ['only' => $filesToSearch]);
        }

        $foundTemplates = [];

        foreach ($files as $fileName) {
            // strip templatePath from current template's full path
            $relativeName = str_replace(Yii::getAlias($this->templatePath) . DIRECTORY_SEPARATOR, "", $fileName);
            $relativeDir = dirname($relativeName) == '.' ? '' : dirname($relativeName) . '/';
            // strip extension
            $relativeName = $relativeDir . basename($relativeName,'.php');
            $foundTemplates[] = $relativeName;
        }

        return $foundTemplates;
    }
139145
public function template_hierarchy( $templates ) {

		$this->type = substr( current_filter(), 0, - 19 ); // Trim '_template_hierarchy' from end.

		$twig_templates = [];

		foreach ( $templates as $php_template ) {
			if ( '.php' === substr( $php_template, - 4 ) ) {
				$twig_templates[] = substr( $php_template, 0, - 4 ) . '.twig';
			}
		}

		return array_merge( $twig_templates, $templates );
	}
87988
protected function fetchFixtures(array $fixtures = null)
    {
        $availableFixtures = glob("{$this->config['location']}/*.php");

        foreach ($availableFixtures as $i => $fixture) {
            $tableName = basename($fixture, '.php');

            if ($fixtures && !in_array($tableName, $fixtures)) {
                unset($availableFixtures[$i]);
            }
        }
        return array_values($availableFixtures);
    }
59430
protected function separateRows($templates)
    {
        $rows = [];
        foreach ($templates as $template) {
            $rows[] = $template;
            $rows[] = new TableSeparator();
        }
        unset($rows[count($rows) - 1]);

        return $rows;
    }
1035695
protected function getTemplate($templatePath)
    {
        $path = base_path('resources/generator-templates/'.$templatePath.'.stub');

        if (!file_exists($path)) {
            $path = __DIR__.'/../../templates/'.$templatePath.'.stub';
        }

        return $this->fileHelper->get($path);
    }
1218960
protected function parseTemplate($template, array $vars = array())
    {
        if (strpos($template, '{') === false) {
            return $template;
        }

        if (preg_match_all('@\{\$([A-Za-z0-9_]+)\}@i', $template, $matches)) {
            foreach ($matches[1] as $varName) {
                $template = str_replace('{$' . $varName . '}', $vars[$varName], $template);
            }
        }

        return $template;
    }
517038
protected function _templates($customTemplate = null, $customTemplateSuffix = null)
    {
        $templates = SSViewer::get_templates_by_class(static::class, $customTemplateSuffix, __CLASS__);
        // Prefer any custom template
        if ($customTemplate) {
            // Prioritise direct template
            array_unshift($templates, $customTemplate);
        }
        return $templates;
    }
739042
public function listTemplateFolders()
    {

        $this->setUpTemplate();
        $result = [];
        foreach ($this->templateNamespace as $ns => $paths) {
            foreach ($paths as $path) {
                $path = $this->getRootPath() . "/" . $path;
                if ($ns == "") {
                    $result[] = $path;
                } else {
                    $result[] = ['path' => $path, 'namespace' => $ns];
                }
            }
        }

        return $result;
    }
438034
public function addTemplates($templates)
    {
        foreach ($templates as $name => $template) {
            $this->twig->getLoader()->setTemplate($name, $template);
        }
    }
684778
public function findAllTemplates()
    {
        if (null !== $this->templates) {
            return $this->templates;
        }

        $templates = array();

        foreach ($this->paths as $dir) {
            $templates = array_merge($templates, $this->findTemplatesInFolder($dir));
        }

        return $this->templates = $templates;
    }
399505
public function calculateModuleTemplatePath($templateName)
    {
        $moduleList = $this->getModuleList();
        $theme = $this->getTheme();

        $moduleTemplates = $moduleList->getModuleTemplates();
        $activeModules = $moduleList->getActiveModuleInfo();
        $finalTemplatePath = '';

        if (is_array($moduleTemplates) && is_array($activeModules)) {
            foreach ($moduleTemplates as $sModuleId => $aTemplates) {
                // check if module is active
                if (isset($activeModules[$sModuleId])) {
                    $foundTemplate = null;
                    $fileSystem = $this->getFileSystem();

                    // check if template for our active themes exists
                    foreach ((array) $theme->getActiveThemesList() as $oneActiveThemeId) {
                        if (isset($aTemplates[$oneActiveThemeId], $aTemplates[$oneActiveThemeId][$templateName])) {
                            $foundTemplate = $fileSystem->combinePaths($this->getModulesPath(), $aTemplates[$oneActiveThemeId][$templateName]);
                        }
                    }

                    // if not found in theme specific configurations
                    if (!$foundTemplate && isset($aTemplates[$templateName])) {
                        $foundTemplate = $fileSystem->combinePaths($this->getModulesPath(), $aTemplates[$templateName]);
                    }

                    if ($foundTemplate) {
                        if ($fileSystem->isReadable($foundTemplate)) {
                            $finalTemplatePath = $foundTemplate;
                            break;
                        } else {
                            throw oxNew('oxException', sprintf('Cannot find template file "%s".', $foundTemplate));
                        }
                    }
                }
            }
        }

        if (!$finalTemplatePath) {
            throw oxNew('oxException', sprintf('Cannot find template "%s" in modules configuration.', $templateName));
        }

        return $finalTemplatePath;
    }
368254
public function getPaths() : array
    {
        $templatePaths = [];

        $paths = $this->template->getFinder()->getPaths();
        $hints = $this->template->getFinder()->getHints();

        foreach ($paths as $path) {
            $templatePaths[] = new TemplatePath($path);
        }

        foreach ($hints as $namespace => $path) {
            $templatePaths[] = new TemplatePath($namespace, $path);
        }

        return $templatePaths;
    }
1183881
public function collectTemplateData($templateName, $parameters, $templatePath = null)
    {
        $collectedParameters = array();
        foreach ($parameters as $name => $value) {
            $collectedParameters[$name] = array(
                'type' => in_array(gettype($value), array('object', 'resource')) ? get_class($value) : gettype($value),
                'value' => in_array(gettype($value), array('object', 'resource', 'array')) ? null : $value,
            );
        }

        $this->data['templates'][] = array(
            'name'       => $templateName,
            'path'       => $templatePath,
            'parameters' => $collectedParameters
        );
    }
1013832
function templateFile( $templateName )
    {
        if ( isset( $this->Templates[$templateName] ) )
        {
            return $this->Templates[$templateName]['filepath'];
        }
        return false;
    }
4919
protected function getTemplateVars(TemplateInterface $template)
    {
        $vars = [
            'expected' => $this->match->getExpected(),
            'actual' => $this->match->getActual(),
        ];

        if ($tplVars = $template->getTemplateVars()) {
            $vars = array_merge($vars, $tplVars);
        }

        return $vars;
    }
919519
private function fetchTemplateForNamespace($template, $namespace)
    {
        foreach ($this->getTemplatePath($namespace) as $path) {
            if (! empty($path)) {
                $path .= '/';
            }

            $filename = $path . $template;
            if (file_exists($filename)) {
                return file_get_contents($filename);
            }
        }

        return false;
    }
1157725
public function getTemplateNamesForFilename($filename)
    {
        $map = $this->getMap();
        $matching = array_filter(array_keys($map), function ($path) use ($filename) {
            return $filename[0] === $path[0] && 0 === strpos($filename, $path);
        });

        $templateNames = [];
        foreach ($matching as $match) {
            $namespace = $map[$match];
            $templateNames[] = self::MAIN_NAMESPACE === $namespace
                ? ltrim(substr($filename, strlen($match)), '/\\')
                : '@'.$namespace.substr($filename, strlen($match));
        }

        return $templateNames;
    }