. */ /** * Theme Service. This class provides functionality to * handle themes */ require_once(FILESYSTEMROOTPATH."events/include/dao/ThemeDao.php"); class ThemeService { private $themeDao; /** * Default constructor * * @param ThemeDao */ public function __construct(ThemeDao $themeDao) { $this->themeDao = $themeDao; } /** * Load a theme by id * * @param string id of the theme to be loaded * @return Theme containing the data of the requested theme, or NULL in case theme does not exist */ public function load($id) { $theme = $this->themeDao->load($id); $ret = array ("id" => $theme->getId(), "name" => $theme->getName(), "active" => $theme->getActive(), "description" => $theme->getDescription()); return $ret; } /** * Load all Themes * * @return array of Theme */ public function loadAll() { $ret = array(); $themes = $this->themeDao->loadAll(); foreach( $themes as $theme ) { $ret[ $theme->getId() ] = array ("id" => $theme->getId(), "name" => $theme->getName(), "active" => $theme->getActive(), "description" => $theme->getDescription()); } return $ret; } /** * Load all Active Themes * * @return array of Theme */ public function loadActive() { $ret = array(); $themes = $this->themeDao->loadActive(); foreach( $themes as $theme ) { $ret[ $theme->getId() ] = array ("id" => $theme->getId(), "name" => $theme->getName(), "active" => $theme->getActive(), "description" => $theme->getDescription()); } return $ret; } /** * Save or update a theme * * @param Theme object with the theme data * @return boolean true in case of success, false otherwise */ public function saveOrUpdate(IModel $theme) { return $this->themeDao->saveOrUpdate($theme); } }