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

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

public installTheme ( $themeName )
    public function installTheme($themeName)
    {
        $themes = $this->getAvailableThemes();
        if (!isset($themes[$themeName])) {
            throw new \Ip\Exception("Theme '" . esc($themeName) . "' does not exist.");
        }
        $theme = $themes[$themeName];
        ipEvent('ipBeforeThemeInstalled', array('themeName' => $themeName));
        \Ip\ServiceLocator::storage()->set('Ip', 'theme', $themeName);
        $service = Service::instance();
        $service->saveWidgetOptions($theme);
        //write down default theme options
        $options = $theme->getOptionsAsArray();
        foreach ($options as $option) {
            if (empty($option['name']) || empty($option['default'])) {
                continue;
            }
            $configModel = ConfigModel::instance();
            $newValue = $configModel->getConfigValue($themeName, $option['name'], $option['default']);
            $configModel->setConfigValue($themeName, $option['name'], $newValue);
        }
        ipEvent('ipThemeInstalled', array('themeName' => $themeName));
    }