BcUtil::getThemeList PHP Method

getThemeList() public static method

テーマリストを取得する
public static getThemeList ( ) : array
return array
    public static function getThemeList()
    {
        $path = WWW_ROOT . 'theme';
        $folder = new Folder($path);
        $files = $folder->read(true, true);
        $themes = array();
        foreach ($files[0] as $theme) {
            if ($theme != 'core' && $theme != '_notes') {
                $themes[$theme] = $theme;
            }
        }
        return $themes;
    }

Usage Example

 /**
  * サブサイト情報編集
  *
  * @param $id
  */
 public function admin_edit($id)
 {
     if (!$id) {
         $this->notFound();
     }
     if (!$this->request->data) {
         $this->request->data = $this->Site->find('first', ['conditions' => ['Site.id' => $id], 'recursive' => -1]);
         if (!$this->request->data) {
             $this->notFound();
         }
     } else {
         /*** Sites.beforeEdit ** */
         $event = $this->dispatchEvent('beforeEdit', ['data' => $this->request->data]);
         if ($event !== false) {
             $this->request->data = $event->result === true ? $event->data['data'] : $event->result;
         }
         if ($data = $this->Site->save($this->request->data)) {
             /*** Sites.afterEdit ***/
             $this->dispatchEvent('afterEdit', ['data' => $data]);
             $this->setMessage('サブサイト「' . $this->request->data['Site']['name'] . '」を更新しました。', false, true);
             $this->redirect(array('action' => 'edit', $id));
         } else {
             $this->setMessage('入力エラーです。内容を修正してください。', true);
         }
     }
     $this->pageTitle = 'サブサイト編集';
     $defaultThemeName = 'サイト基本設定に従う';
     if (!empty($this->siteConfigs['theme'])) {
         $defaultThemeName .= '(' . $this->siteConfigs['theme'] . ')';
     }
     $themes = BcUtil::getThemeList();
     if (in_array($this->siteConfigs['theme'], $themes)) {
         unset($themes[$this->siteConfigs['theme']]);
     }
     $this->set('mainSites', $this->Site->getSiteList(0, ['excludeIds' => $this->request->data['Site']['id']]));
     $this->set('themes', array_merge(['' => $defaultThemeName], $themes));
     $this->help = 'sites_form';
 }