Newscoop\Service\Implementation\ThemeManagementServiceLocal::getTemplates PHP Method

getTemplates() public method

public getTemplates ( $theme )
    public function getTemplates($theme)
    {
        Validation::notEmpty($theme, 'theme');
        if ($theme instanceof Theme) {
            $themePath = $theme->getPath();
        } else {
            $themePath = $theme;
        }
        $resources = array();
        $folder = $this->toFullPath($themePath);
        if (is_dir($folder)) {
            if ($dh = opendir($folder)) {
                while (($file = readdir($dh)) !== false) {
                    if ($file != "." && $file != "..") {
                        if (pathinfo($file, PATHINFO_EXTENSION) === self::FILE_TEMPLATE_EXTENSION) {
                            $rsc = new Resource();
                            $rsc->setName($file);
                            $rsc->setPath($themePath . $file);
                            $resources[] = $rsc;
                        }
                    }
                }
                closedir($dh);
            }
        }
        return $resources;
    }