### app binding : xe.config 로 바인딩 되어 있음 XeConfig Facade 로 접근 가능 ### 등록 php XeConfig::add('head.child', ['key1' => 'val1', 'key2' => 'val2']); 또는 XeConfig::set('head.child', ['key1' => 'val1', 'key2' => 'val2']); ### 반환 config 정보를 객체의 반환, 특정 키에대한 값의 반환 두가지 를 지원 합니다. php 객체 반환 $config = XeConfig::get('head.child'); 값의 반환 $val = XeConfig::getVal('head.child.key1'); 특정 키에 값이 설정되어있지 않은경우 반환 받고 싶은 값이 있다면 두번째 인자에 포함시키면 됩니다. $val = XeConfig::getVal('head.child.key1', 'default'); 객체 반환시 만일 존재 하지 않는 경우 부모를 참조하는 객체로 반환 받을 수 있습니다. php 'head.child' 의 값을 참조 $config = XeConfig::getOrNew('head.child.unknown'); ### 수정 패키지에서는 몇가지 형태의 수정방식을 제공합니다. php 지정된 키에 해당하는 값만 수정 XeConfig::set('head.child', ['key2' => 'new value']); 전체에 대한 수정 (다음과 같은 경우 'key2' 를 제외한 모든 값이 사라집니다.) XeConfig::put('head.child', ['key2' => 'new value']); 객체에 의한 수정 XeConfig::modify($config); 수정시 자손에 해당 하는 모든 하위 노드의 값도 일괄적으로 수정할 수 있습니다. php XeConfig::set('head.child', ['key2' => 'new value'], true); 필터를 작성하면 true 인 경우에 해당하는 자손만 수정 됩니다. XeConfig::set('head.child', ['key2' => 'new value'], true, function ($config) { return substr($config->name, 0, 4) != 'desc'; }); #### 객체의 사용 ConfigEntity 객채는 배열 처럼 사용 가능합니다. php $val = $config['key']; loop foreach ($config as $key => $val) { do something }
Author: XE Developers (developers@xpressengine.com)
 public function postDetailSetting(Request $request, EditorHandler $handler, ConfigManager $configs, $instanceId)
 {
     $this->validate($request, ['height' => 'required|numeric', 'fontSize' => 'required', 'fileMaxSize' => 'numeric', 'attachMaxSize' => 'numeric']);
     $configs->set($handler->getConfigKey($instanceId), ['height' => $request->get('height'), 'fontSize' => $request->get('fontSize'), 'fontFamily' => empty($request->get('fontFamily')) ? null : $request->get('fontFamily'), 'uploadActive' => !!$request->get('uploadActive', false), 'fileMaxSize' => $request->get('fileMaxSize', 0), 'attachMaxSize' => $request->get('attachMaxSize', 0), 'extensions' => empty($request->get('extensions')) ? null : strtolower($request->get('extensions')), 'tools' => $request->get('tools', [])]);
     $this->permissionRegister($request, $handler->getPermKey($instanceId), ['html', 'tool', 'upload', 'download']);
     return redirect()->route('settings.editor.setting.detail', $instanceId);
 }
 /**
  * index
  *
  * @return RendererInterface
  */
 public function index()
 {
     $instanceConfig = InstanceConfig::instance();
     $instanceId = $instanceConfig->getInstanceId();
     $configName = $this->getConfigKeyString($instanceId);
     $includePath = $this->configManager->getVal($configName);
     return XePresenter::make('show', ['includePath' => $includePath]);
 }
Esempio n. 3
0
 /**
  * getSiteConfigValue
  *
  * @param string      $key     value key
  * @param string|null $siteKey site key
  *
  * @return string
  */
 public function getSiteConfigValue($key, $siteKey = null)
 {
     if (is_null($siteKey)) {
         $siteKey = $this->currentSite->siteKey;
     }
     return $this->config->getVal(sprintf("site.%s.%s", $siteKey, $key));
 }
Esempio n. 4
0
 /**
  * Set setting information
  *
  * @param array $data setting data
  * @return void
  */
 public function set(array $data)
 {
     $this->config = $this->cfg->set($this->key, $data);
     if (!$this->config->get('uuid')) {
         $this->config->set('uuid', $this->keygen->generate());
         $this->cfg->modify($this->config);
     }
 }
 /**
  * 활성화된 아이템 목록을 반환
  *
  * @param string      $id         target plugin id
  * @param string|null $instanceId instance id
  * @return array
  */
 public function getActivated($id, $instanceId = null)
 {
     $config = $this->cfg->getOrNew($this->getConfigKey($id, $instanceId));
     $keys = $config->get('activate', []);
     $activated = array_intersect_key($this->all($id), array_flip($keys));
     // sort
     $activated = array_merge(array_flip($keys), $activated);
     return array_filter($activated, function ($val) {
         return class_exists($val);
     });
 }
 /**
  * Get editor by instance id
  *
  * @param string $instanceId instance id
  * @return AbstractEditor
  */
 public function get($instanceId)
 {
     if (!($editorId = $this->getEditorId($instanceId))) {
         $editorId = $this->getDefaultEditorId();
     }
     $class = $this->register->get($editorId);
     /** @var AbstractEditor $editor */
     $editor = $this->container->make($class, ['instanceId' => $instanceId]);
     $editor->setConfig($this->configManager->getOrNew($this->getConfigKey($instanceId)));
     return $editor;
 }
 /**
  * 주어진 타겟에 지정된 스킨의 설정을 저장한다.
  *
  * @param string $key    target key
  * @param string $skinId skin id
  * @param array  $config skin config data
  *
  * @return void
  */
 public function setConfigs($key, $skinId, $config = null)
 {
     if ($config === null) {
         $config = $skinId;
         $skinId = null;
     }
     $key = $this->makeStoreKey(static::PREFIX_KEY_CONFIGS, $key);
     if ($skinId === null) {
         $this->store->set($key, $config);
     } else {
         $this->store->setVal("{$key}.{$skinId}", $config);
     }
 }
 /**
  * 활성화된 아이템 목록을 반환
  *
  * @param string      $id         target plugin id
  * @param string|null $instanceId instance id
  * @return array
  */
 public function getActivated($id, $instanceId = null)
 {
     // todo: 임시? seed 로 추가되면 제거?
     if ($this->cfg->get($this->getConfigKey($id, null)) === null) {
         $this->cfg->set($this->getConfigKey($id, null), []);
     }
     if (($config = $this->cfg->get($this->getConfigKey($id, $instanceId))) === null) {
         $config = $this->setActivates($id, $instanceId);
     }
     $keys = $config->get('activate', []);
     $activated = array_intersect_key($this->all($id), array_flip($keys));
     // sort
     $activated = array_merge(array_flip($keys), $activated);
     return array_filter($activated, function ($val) {
         return !empty($val);
     });
 }
 /**
  * 관리페이지 관련 설정을 조회한다.
  *
  * @param string $config 설정 키
  *
  * @return ConfigEntity
  */
 public function getConfig($config)
 {
     return $this->configManager->get(static::SETTING_CONFIG_NAME . '.' . $config);
 }
Esempio n. 10
0
 /**
  * Move menu item config consisting of theme identifiers
  *
  * @param MenuItem $beforeItem before item
  * @param MenuItem $movedItem  after item
  * @return void
  */
 public function moveItemConfig(MenuItem $beforeItem, MenuItem $movedItem)
 {
     $configEntity = $this->configs->get($this->menuKeyString($beforeItem));
     $to = $this->menuKeyString($movedItem);
     $this->configs->move($configEntity, substr($to, 0, strrpos($to, '.')));
 }
Esempio n. 11
0
 /**
  * 플러그인 상태정보를 갱신한다.
  *
  * @param array $configs status list
  *
  * @return void
  */
 protected function setPluginsStatus(array $configs)
 {
     $this->config->setVal($this->configKey, $configs);
 }
 /**
  * moveItemConfig
  *
  * @param MenuItem $beforeItem to change theme value for before item moving
  * @param MenuItem $movedItem  to change theme value for after item moving
  *
  * @return void
  * @throws InvalidArgumentException
  */
 public function moveItemConfig(MenuItem $beforeItem, MenuItem $movedItem)
 {
     $configEntity = $this->configManager->get($this->menuKeyString($beforeItem->getBreadCrumbsKeyString()));
     $this->configManager->move($configEntity, $this->menuKeyString($movedItem->getBreadCrumbsKeyString(true)));
 }
Esempio n. 13
0
 /**
  * updatePageConfig
  *
  * @param ConfigEntity $config page config entity
  *
  * @return void
  * @throws \Xpressengine\Config\Exceptions\InvalidArgumentException
  */
 public function updatePageConfig($config)
 {
     $this->configManager->modify($config);
 }
Esempio n. 14
0
 /**
  * set config
  *
  * @param string $counterName counter name
  * @param string $type        counter type
  * @return void
  */
 public function set($counterName, $type = Counter::TYPE_ID)
 {
     $config = $this->configManager->get($this->name);
     $config->set($counterName, $type);
     $this->configManager->put($this->name, $config->getPureAll());
 }
Esempio n. 15
0
 /**
  * parent config 설정
  *
  * @param string $group group name
  * @return void
  * @throws \Xpressengine\Config\Exceptions\InvalidArgumentException
  */
 public function setParent($group)
 {
     $this->configManager->add(sprintf('%s.%s', self::CONFIG_NAME, $group), []);
 }
 /**
  * Put a comment
  *
  * @param CommentEntity $comment comment instance
  * @return CommentEntity
  */
 public function put(CommentEntity $comment)
 {
     $config = $this->configs->get($this->getConfigKey($comment->instanceId));
     if ($config->get('useWysiwyg') === true) {
         $comment->html = 1;
     }
     $updated = $this->repo->update($comment);
     return $this->member->associate($updated);
 }
 /**
  * Process to delete
  *
  * @param $instanceId
  *
  * @return mixed
  */
 public function deleteMenu($instanceId)
 {
     $configName = $this->getPageConfigKeyString($instanceId);
     $this->configManager->removeByName($configName);
 }
Esempio n. 18
0
 /**
  * drop document instance
  *
  * @param ConfigEntity $config config
  * @return void
  */
 public function remove(ConfigEntity $config)
 {
     $this->configManager->remove($config);
 }
Esempio n. 19
0
 /**
  * get board config
  *
  * @param string $boardId board id
  * @return ConfigEntity
  */
 public function get($boardId)
 {
     $config = $this->configManager->get($this->name($boardId));
     return $config;
 }
Esempio n. 20
0
 public function testMoveFromChildToAnotherChild()
 {
     list($repo, $validator) = $this->getMocks();
     $instance = new ConfigManager($repo, $validator);
     $mockParent = m::mock('Xpressengine\\Config\\ConfigEntity');
     $mockConfig = m::mock('Xpressengine\\Config\\ConfigEntity');
     $mockConfig->shouldReceive('getParent')->andReturn($mockParent);
     $mockConfig->shouldReceive('getDepth')->andReturn(2);
     $mockConfig->siteKey = 'default';
     $mockConfig->name = 'board.notice';
     $mockToConfig = m::mock('Xpressengine\\Config\\ConfigEntity');
     $repo->shouldReceive('find')->once()->with('default', 'valid.to')->andReturn($mockToConfig);
     $repo->shouldReceive('foster')->once()->with($mockConfig, 'valid.to');
     $mockConfig->shouldReceive('setParent')->once()->with($mockToConfig)->andReturnNull();
     $repo->shouldReceive('find')->once()->with('default', 'valid.to.notice')->andReturn($mockConfig);
     $repo->shouldReceive('fetchParent')->with('default', 'valid.to.notice')->andReturn([$mockToConfig]);
     $instance->move($mockConfig, 'valid.to');
 }
 /**
  * instance 별 설정 정보를 반환
  *
  * @param string $instanceId instance identifier
  * @return \Xpressengine\Config\ConfigEntity
  */
 protected function getConfig($instanceId)
 {
     return $this->configs->get($this->prefix . '.' . $instanceId);
 }