getOrNew() public method

if not exists, create new entity object by target name
public getOrNew ( string $group, string $siteKey = 'default' ) : ConfigEntity
$group string the name of target
$siteKey string site key
return ConfigEntity
 /**
  * 활성화된 아이템 목록을 반환
  *
  * @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;
 }
 public function getDetailSetting(EditorHandler $handler, ConfigManager $configs, $instanceId)
 {
     $config = $configs->getOrNew($handler->getConfigKey($instanceId));
     $tools = $handler->getToolAll();
     $toolIds = $config->get('tools', []);
     $activated = array_intersect_key($tools, array_flip($toolIds));
     $activated = array_merge(array_flip($toolIds), $activated);
     $deactivated = array_diff_key($tools, array_flip($toolIds));
     $items = [];
     foreach ($activated as $key => $item) {
         $items[$key] = ['class' => $item, 'activated' => true];
     }
     foreach ($deactivated as $key => $item) {
         $items[$key] = ['class' => $item, 'activated' => false];
     }
     return XePresenter::make('editor.detail', ['instanceId' => $instanceId, 'config' => $config, 'permArgs' => $this->getPermArguments($handler->getPermKey($instanceId), ['html', 'tool', 'upload', 'download']), 'items' => $items]);
 }
 public function testGetsOrNewRetunsEntityObjectEvenIfNotExists()
 {
     list($repo, $validator) = $this->getMocks();
     $ancestor = m::mock('Xpressengine\\Config\\ConfigEntity');
     $ancestor->name = 'board';
     $repo->shouldReceive('find')->once()->with('default', 'board.notice')->andReturnNull();
     $repo->shouldReceive('fetchParent')->with('default', 'board.notice')->andReturn([$ancestor]);
     $instance = new ConfigManager($repo, $validator);
     $config = $instance->getOrNew('board.notice');
     $this->assertInstanceOf('Xpressengine\\Config\\ConfigEntity', $config);
     $this->assertEquals('board.notice', $config->name);
 }
 /**
  * config 객체를 반환함
  *
  * @param string $instanceId instance identifier
  * @return \Xpressengine\Config\ConfigEntity
  */
 public function getConfig($instanceId)
 {
     //        return $this->configs->getOrNew($this->getConfigKey($instanceId));
     $config = $this->configs->get($this->getConfigKey($instanceId));
     if ($config === null) {
         $config = $this->configs->getOrNew($this->getConfigKey($instanceId));
         foreach ($this->defaultConfig as $key => $value) {
             $config->set($key, $value);
         }
     }
     return $config;
 }