public function registerTheme($id, $name, $path = '', $targets = array(), $templates = array() )
    {
        if (preg_match('/^[a-zA-Z0-9]*$/', $id) === 0) {
            throw new \common_Exception('Invalid id "'.$id.'"');
        }
        if (!is_array($targets) || count($targets) === 0){
            throw new \common_Exception('No targets were provided for theme '.$id);
        }

        foreach ($targets as $target) {
            if(!$this->isRegistered($target)){
                throw new \common_Exception('Target '.$target.' does not exist');
            } else {

                $array = $this->get($target);

                foreach ($array['available'] as $theme) {
                    if ($theme['id'] == $id) {
                        throw new \common_Exception('Theme '.$id.' already exists for target '.$target);
                    }
                }

                $theme = array(
                    'id' => $id,
                    'name' => $name
                );

                //the path is optional
                if($path){
                    $theme['path'] = $path;
                }

                //register templates
                if(is_array($templates) && count($templates) > 0){
                    $theme['templates'] = array();
                    foreach($templates as $templateId => $tpl){
                        $theme['templates'][$templateId] = $tpl;
                    }
                }

                $array['available'][] = $theme;
            }
            $this->set($target, $array);
        }
    }
public function registerTheme($id, $name, $path = '', $targets = array(), $templates = array() )
    {
        if (preg_match('/^[a-zA-Z0-9]*$/', $id) === 0) {
            throw new \common_Exception('Invalid id "'.$id.'"');
        }
        if (!is_array($targets) || count($targets) === 0){
            throw new \common_Exception('No targets were provided for theme '.$id);
        }

        foreach ($targets as $target) {
            if(!$this->isRegistered($target)){
                throw new \common_Exception('Target '.$target.' does not exist');
            } else {

                $array = $this->get($target);

                foreach ($array['available'] as $theme) {
                    if ($theme['id'] == $id) {
                        throw new \common_Exception('Theme '.$id.' already exists for target '.$target);
                    }
                }

                $theme = array(
                    'id' => $id,
                    'name' => $name
                );

                //the path is optional
                if($path){
                    $theme['path'] = $path;
                }

                //register templates
                if(is_array($templates) && count($templates) > 0){
                    $theme['templates'] = array();
                    foreach($templates as $templateId => $tpl){
                        $theme['templates'][$templateId] = $tpl;
                    }
                }

                $array['available'][] = $theme;
            }
            $this->set($target, $array);
        }
    }
public function registerTheme ( $ id , $ name , $ path = '' , $ targets = array ( ) , $ templates = array ( ) ) { if ( preg_match ( '/^[a-zA-Z0-9]*$/' , $ id ) === 0 ) { throw new \ common_Exception ( 'Invalid id "' . $ id . '"' ) ; } if ( ! is_array ( $ targets ) || count ( $ targets ) === 0 ) { throw new \ common_Exception ( 'No targets were provided for theme ' . $ id ) ; } foreach ( $ targets as $ target ) { if ( ! $ this -> isRegistered ( $ target ) ) { throw new \ common_Exception ( 'Target ' . $ target . ' does not exist' ) ; } else { $ array = $ this -> get ( $ target ) ; foreach ( $ array [ 'available' ] as $ theme ) { if ( $ theme [ 'id' ] == $ id ) { throw new \ common_Exception ( 'Theme ' . $ id . ' already exists for target ' . $ target ) ; } } $ theme = array ( 'id' => $ id , 'name' => $ name ) ; //the path is optional if ( $ path ) { $ theme [ 'path' ] = $ path ; } //register templates if ( is_array ( $ templates ) && count ( $ templates ) > 0 ) { $ theme [ 'templates' ] = array ( ) ; foreach ( $ templates as $ templateId => $ tpl ) { $ theme [ 'templates' ] [ $ templateId ] = $ tpl ; } } $ array [ 'available' ] [ ] = $ theme ; } $ this -> set ( $ target , $ array ) ; } }
Adds a theme to the registry

@author Lionel Lecaque, lionel@taotesting.com
@param string $id
@param string $name
@param string $path
@param array $targets
@throws \common_Exception
Adds a theme to the registry