Streamline Theme object API (::load should be static as in CmsObject)

This commit is contained in:
Samuel Georges 2014-11-19 17:45:57 +11:00
parent 7801750767
commit f351697c48
1 changed files with 20 additions and 8 deletions

View File

@ -47,10 +47,13 @@ class Theme
/**
* Loads the theme.
* @return self
*/
public function load($dirName)
public static function load($dirName)
{
$this->dirName = $dirName;
$theme = new static;
$theme->setDirName($dirName);
return $theme;
}
/**
@ -67,6 +70,15 @@ class Theme
return base_path().Config::get('cms.themesDir').'/'.$dirName;
}
/**
* Sets the theme directory name.
* @return void
*/
public function setDirName($dirName)
{
$this->dirName = $dirName;
}
/**
* Returns the theme directory name.
* @return string
@ -135,8 +147,8 @@ class Theme
throw new SystemException(Lang::get('cms::lang.theme.active.not_set'));
}
$theme = new static;
$theme->load($activeTheme);
$theme = static::load($activeTheme);
if (!File::isDirectory($theme->getPath())) {
return self::$activeThemeCache = null;
}
@ -184,8 +196,8 @@ class Theme
throw new SystemException(Lang::get('cms::lang.theme.edit.not_set'));
}
$theme = new static;
$theme->load($editTheme);
$theme = static::load($editTheme);
if (!File::isDirectory($theme->getPath())) {
return self::$editThemeCache = null;
}
@ -210,8 +222,8 @@ class Theme
continue;
}
$theme = new static;
$theme->load($fileinfo->getFilename());
$theme = static::load($fileinfo->getFilename());
$result[] = $theme;
}