listToArray() 공개 정적인 메소드

public static listToArray ( string $string ) : array
$string string a comma separated list of values
리턴 array
예제 #1
0
 /**
  * @ApiDoc(
  *  section="Backend",
  *  description="Returns a array with settings for the administration interface"
  * )
  *
  * items:
  *  modules
  *  configs
  *  layouts
  *  contents
  *  navigations
  *  themes
  *  themeProperties
  *  user
  *  groups
  *  langs
  *
  *  Example: settings?keys[]=modules&keys[]=layouts
  *
  * @Rest\QueryParam(name="keys", map=true, requirements=".+", description="List of config keys to filter"))
  *
  * @Rest\Get("/admin/backend/settings")
  *
  * @param ParamFetcher $paramFetcher
  *
  * @return array
  */
 public function getSettingsAction(ParamFetcher $paramFetcher)
 {
     $keys = $paramFetcher->get('keys');
     $loadKeys = $keys;
     if (!$loadKeys) {
         $loadKeys = false;
     }
     $res = array();
     if ($loadKeys == false || in_array('modules', $loadKeys)) {
         foreach ($this->jarves->getConfigs() as $config) {
             $res['bundles'][] = $config->getBundleName();
         }
     }
     if ($loadKeys == false || in_array('configs', $loadKeys)) {
         $res['configs'] = $this->jarves->getConfigs()->toArray();
     }
     if ($loadKeys == false || in_array('themes', $loadKeys)) {
         foreach ($this->jarves->getConfigs() as $key => $config) {
             if ($config->getThemes()) {
                 foreach ($config->getThemes() as $themeTitle => $theme) {
                     /** @var $theme \Jarves\Configuration\Theme */
                     $res['themes'][$theme->getId()] = $theme->toArray();
                 }
             }
         }
     }
     if ($loadKeys == false || in_array('upload_max_filesize', $loadKeys)) {
         $v = ini_get('upload_max_filesize');
         $v2 = ini_get('post_max_size');
         $b = $this->toBytes($v < $v2 ? $v : $v2);
         $res['upload_max_filesize'] = $b;
     }
     if ($loadKeys == false || in_array('groups', $loadKeys)) {
         $res['groups'] = GroupQuery::create()->find()->toArray(null, null, TableMap::TYPE_CAMELNAME);
     }
     if ($loadKeys == false || in_array('user', $loadKeys)) {
         $user = $this->pageStack->getUser();
         if ($settings = $user->getSettings()) {
             if ($settings instanceof Properties) {
                 $res['user'] = $settings->toArray();
             }
         }
         if (!isset($res['user'])) {
             $res['user'] = array();
         }
     }
     if ($loadKeys == false || in_array('system', $loadKeys)) {
         $system = clone $this->jarves->getSystemConfig();
         $system->setDatabase(null);
         $system->setPasswordHashKey('');
         $res['system'] = $system->toArray();
     }
     if ($loadKeys == false || in_array('domains', $loadKeys)) {
         $res['domains'] = $this->container->get('jarves.objects')->getList('JarvesBundle:Domain', null, array('permissionCheck' => true));
     }
     if ($loadKeys == false || in_array('langs', $loadKeys)) {
         $codes = Tools::listToArray($this->jarves->getSystemConfig()->getLanguages());
         $query = LanguageQuery::create()->filterByCode($codes);
         $tlangs = $query->find()->toArray(null, null, TableMap::TYPE_CAMELNAME);
         $langs = [];
         foreach ($tlangs as $lang) {
             $langs[$lang['code']] = $lang;
         }
         #$langs = dbToKeyIndex($tlangs, 'code');
         $res['langs'] = $langs;
     }
     return $res;
 }
예제 #2
0
 /**
  * @return array
  */
 public function getExtraSelection()
 {
     if (is_string($this->extraSelection)) {
         return Tools::listToArray($this->extraSelection);
     }
     return $this->extraSelection;
 }