@param Theme $theme

@return Theme
166952
private function mergePageTemplates(Theme $theme)
    {
        if ($theme->getParentTheme()) {
            $parentTheme = $this->getTheme($theme->getParentTheme());

            foreach ($parentTheme->getPageTemplates() as $parentPageTemplate) {
                $theme->addPageTemplate($parentPageTemplate);
            }

            foreach ($parentTheme->getPageTemplateTitles() as $route => $title) {
                if (!$theme->getPageTemplateTitle($route)) {
                    $theme->addPageTemplateTitle($route, $title);
                }
            }
        }

        return $theme;
    }
370921
public function symlinkWithFindInherit($theme)
    {
        $trace = debug_backtrace();

        if (! isset($trace[1])) return;

        // change backslash to forward slash (for windows file system)
        $path = str_replace("\\", "/", array_get($trace[1], 'file'));

        $config = $this->getConfig();

        $link = preg_replace("#(public/{$config['themeDir']}/)[^/]+#", "$1{$theme}", $path);

        extract($this->arguments);
        extract($this->view->getShared());

        return require($link);
    }
1115904
public function setTheme(string $theme): FieldTypeInterface
    {
        $this->options['theme'] = $theme;

        // Update all attached fields with the given theme.
        foreach ($this->repository->all() as $field) {
            /** @var FieldTypeInterface $field */
            $field->setTheme($theme);
        }

        // Update all attached groups with the given theme.
        foreach ($this->repository()->getGroups() as $group) {
            /** @var SectionInterface $group */
            $group->setTheme($theme);
        }

        return $this;
    }
1320702
private function getTheme($themeName)
    {
        $theme = $this->themeRepository->findOneByName($themeName);
        if (null === $theme) {
            throw new NotFoundHttpException(sprintf('Theme with name "%s" not found', $themeName));
        }

        return $theme;
    }
844731
protected function getBasePath(Theme $theme = null) : string
    {
        $theme = $theme ?? $this->getTheme();

        if (isset($this->fullPaths[$theme->getKey()])) {
            return $this->fullPaths[$theme->getKey()];
        }

        return $this->fullPaths[$theme->getKey()] = $this->createPath($theme->getPath(), $this->directory);
    }
1211851
public function addTheme(ThemeInterface $theme, $key, $default = false)
    {
        $this->themes[$key] = $theme;

        if ($default) {
            $this->default = $key;
        }

        return true;
    }
198288
public function symlink($theme)
    {
        $trace = debug_backtrace();

        if (! isset($trace[1])) return;

        $link = str_replace($this->getThemeName(), $theme, array_get($trace[1], 'file'));

        extract($this->arguments);
        extract($this->view->getShared());

        return require($link);
    }
810079
public function setCurrentTheme($theme, $deviceType)
    {
        $this->lastTheme = $theme;

        $paths = $this->basePaths;

        // add active theme as Resources/themes/views folder as well.
        $paths[] = $this->path.'/themes/'.$theme;
        $paths[] = $this->path;

        $this->paths = $paths;
    }
1198537
public static function load($themename) {
        global $CFG;

        // load theme settings from db
        try {
            $settings = get_config('theme_'.$themename);
        } catch (dml_exception $e) {
            // most probably moodle tables not created yet
            $settings = new stdClass();
        }

        if ($config = theme_config::find_theme_config($themename, $settings)) {
            return new theme_config($config);

        } else if ($themename == theme_config::DEFAULT_THEME) {
            throw new coding_exception('Default theme '.theme_config::DEFAULT_THEME.' not available or broken!');

        } else if ($config = theme_config::find_theme_config($CFG->theme, $settings)) {
            debugging('This page should be using theme ' . $themename .
                    ' which cannot be initialised. Falling back to the site theme ' . $CFG->theme, DEBUG_NORMAL);
            return new theme_config($config);

        } else {
            // bad luck, the requested theme has some problems - admin see details in theme config
            debugging('This page should be using theme ' . $themename .
                    ' which cannot be initialised. Nor can the site theme ' . $CFG->theme .
                    '. Falling back to ' . theme_config::DEFAULT_THEME, DEBUG_NORMAL);
            return new theme_config(theme_config::find_theme_config(theme_config::DEFAULT_THEME, $settings));
        }
    }
224326
public static function theme($theme = null)
    {
        if (!self::$_initialized) {
            self::init();
        }

        if ($theme !== null) {
            if (!isset(self::$_themes[$theme])) {
                throw new Exception(__d('wasabi_cms', 'Theme "{0}" does not exist.', $theme));
            }
            self::$_theme = self::$_themes[$theme];
        }

        return self::$_theme;
    }
623626
public function theme_should_be_activated( $theme )
	{
		$theme = $this->replace_variables( $theme );
		$current_theme = $this->get_current_theme();

		if ( $theme !== $current_theme ) {
			throw new \Exception( sprintf(
				"The current theme is %s, but it should be %s",
				$current_theme,
				$theme
			) );
		}
	}
873926
protected function create_theme_array($theme)
	{
		if ( ! is_array($theme))
		{
			if ( ! $path = $this->find($theme))
			{
				throw new \ThemeException(sprintf('Theme "%s" could not be found.', $theme));
			}

			$theme = array(
				'name' => $theme,
				'path' => $path,
			);
		}
		else
		{
			if ( ! isset($theme['name']) or ! isset($theme['path']))
			{
				throw new \ThemeException('Theme name and path must be given in array config.');
			}
		}

		// load the theme info file
		if ( ! isset($theme['info']))
		{
			$theme['info'] = $this->load_info($theme);
		}

		if ( ! isset($theme['asset_base']))
		{
			// determine the asset location and base URL
			$assets_folder = rtrim($this->config['assets_folder'], DS).'/';

			// all theme files are inside the docroot
			if (strpos($path, DOCROOT) === 0 and is_dir($path.$assets_folder))
			{
				$theme['asset_path'] = $path.$assets_folder;
				$theme['asset_base'] = str_replace(DOCROOT, '', $theme['asset_path']);
			}

			// theme views and templates are outside the docroot
			else
			{
				$theme['asset_base'] = $assets_folder.$theme['name'].'/';
			}
		}

		if ( ! isset($theme['asset_path']) and strpos($theme['asset_base'], '://') === false)
		{
			$theme['asset_path'] = DOCROOT.$theme['asset_base'];
		}

		// always uses forward slashes (DS is a backslash on Windows)
		$theme['asset_base'] = str_replace(DS, '/', $theme['asset_base']);

		return $theme;
	}
1109714
protected function getThemeBaseUrl(?Theme $theme = null) : string
    {
        $theme = $theme ?? $this->getTheme();

        if (isset($this->webPaths[$theme->getKey()])) {
            return $this->webPaths[$theme->getKey()];
        }

        return $this->webPaths[$theme->getKey()] = $this->url->make(new UrlSettings([
            'domain'        => $theme->getWebPath(),
            'path'          => $this->directory,
        ]));
    }
1362262
public function build( $id, $theme = "default" )
	{
		return $this->create( $id, $this->content, $this->header, $this->abstract, $this->footer, $theme, $this->attributes );
	}
1074043
protected function set_theme($theme = null, $type = 'active')
	{
		// set the theme if given
		if ($theme !== null)
		{
			// remove the defined theme asset paths from the asset instance
			empty($this->active['asset_path']) or $this->asset->remove_path($this->active['asset_path']);
			empty($this->fallback['asset_path']) or $this->asset->remove_path($this->fallback['asset_path']);

			$this->{$type} = $this->create_theme_array($theme);

			// add the asset paths to the asset instance
			empty($this->fallback['asset_path']) or $this->asset->add_path($this->fallback['asset_path']);
			empty($this->active['asset_path']) or $this->asset->add_path($this->active['asset_path']);
		}

		// and return the theme config
		return $this->{$type};
	}
153753
public function theme($theme = null)
    {
        deprecationWarning(
            'View::theme() is deprecated. ' .
            'Use getTheme()/setTheme() instead.'
        );

        if ($theme === null) {
            return $this->theme;
        }

        $this->theme = $theme;
    }
774666
public function deleteThemeDb($theme)
	{
		if($theme != null) {
			$model = OmmuThemes::model()->findByAttributes(array('folder'=>$theme));
			
			if($model != null)
				$model->delete();
			else 
				return false;

		} else 
			return false;
	}