Ip\Internal\Design\Model::getTheme PHP Метод

getTheme() публичный Метод

Read theme config and create theme entity
public getTheme ( $name, null $dir = null, null $url = null ) : Ip\Internal\Design\Theme
$name
$dir null
$url null
Результат Ip\Internal\Design\Theme
    public function getTheme($name, $dir = null, $url = null)
    {
        if ($dir == null) {
            $dir = ipFile('Theme/');
        }
        $metadata = new ThemeMetadata();
        $metadata->setName($name);
        //new type config
        $themeJsonFile = $dir . $name . '/' . self::INSTALL_DIR . 'Theme.json';
        if (file_exists($themeJsonFile)) {
            $config = $this->parseThemeJson($themeJsonFile);
        } else {
            $themeJsonFile = $dir . $name . '/' . self::INSTALL_DIR . 'theme.json';
            if (file_exists($themeJsonFile)) {
                $config = $this->parseThemeJson($themeJsonFile);
            } else {
                $config = array();
            }
        }
        $config = ipFilter('ipThemeConfig', $config);
        $metadata->setTitle(!empty($config['title']) ? $config['title'] : $name);
        if (!empty($config['author'])) {
            $metadata->setAuthorTitle($config['author']);
        }
        if (!empty($config['version'])) {
            $metadata->setVersion($config['version']);
        }
        if (!empty($config['thumbnail'])) {
            $metadata->setThumbnail($config['thumbnail']);
        }
        if (!empty($url)) {
            $metadata->setUrl($url);
        }
        if (!empty($config['doctype']) && defined('\\Ip\\View::' . $config['doctype'])) {
            $metadata->setDoctype('DOCTYPE_' . $config['doctype']);
        } else {
            $metadata->setDoctype('DOCTYPE_HTML5');
        }
        if (!empty($config['options'])) {
            $metadata->setOptions($config['options']);
        }
        if (!empty($config['widget'])) {
            $metadata->setWidgetOptions($config['widget']);
        }
        $theme = new Theme($metadata);
        return $theme;
    }