get() public method

get value, chain of responsibility
public get ( string $name, mixed $default = null ) : mixed
$name string variable name
$default mixed default value
return mixed
 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);
     }
 }
示例#2
0
 /**
  * get slug url by document id
  * document 에서 지원하는 slug 주소 반환
  *
  * @param string $id document id
  * @return string
  */
 public function getSlugById($id)
 {
     $slug = $this->slug->findById($id, $this->config->get('boardId'));
     if ($slug === null) {
         return '';
     }
     return $this->getSlug($slug->slug);
 }
示例#3
0
 /**
  * get slug url by document id
  * document 에서 지원하는 slug 주소 반환
  *
  * @param string $id document id
  * @return string
  */
 public function getSlugById($id)
 {
     $slug = Slug::where(id, $id)->where('instanceId', $this->config->get('boardId'));
     if ($slug === null) {
         return '';
     }
     return $this->getSlug($slug->slug);
 }
 /**
  * 리스트에서 검색할 때 검색 form 에 사용될 html 코드 반환
  * return html tag string
  *
  * @param array $args arguments
  * @return string
  */
 public function search(array $args)
 {
     if ($this->config->get('searchable') !== true) {
         return '';
     }
     list($data, $key) = $this->filter($args);
     $viewFactory = $this->handler->getViewFactory();
     return $viewFactory->make($this->getViewPath('search'), ['config' => $this->config, 'data' => array_merge($data, $this->mergeData), 'key' => $key])->render();
 }
示例#5
0
 /**
  * Dynamic Field 설정 페이지에서 각 fieldType 에 필요한 설정 등록 페이지 반환
  * return html tag string
  *
  * @param ConfigEntity $config config entity
  * @return string
  */
 public function getSettingsView(ConfigEntity $config = null)
 {
     $category = null;
     if ($config != null) {
         $category = CategoryModel::find($config->get('categoryId'));
     }
     XeFrontend::rule('dynamicFieldSection', $this->getSettingsRules());
     return View::make('dynamicField/category/createType', ['config' => $config, 'category' => $category])->render();
 }
示例#6
0
 /**
  * get value, chain of responsibility
  *
  * @param string $name    variable name
  * @param mixed  $default default value
  * @return mixed
  */
 public function get($name, $default = null)
 {
     $var = $this->getPure($name);
     if ($var !== null) {
         return $var instanceof \Closure ? $var($this) : $var;
     } elseif ($this->parent !== null) {
         return $this->parent->get($name, $default);
     }
     return $default;
 }
示例#7
0
 /**
  * inputs
  *
  * @param ConfigEntity $config board config entity
  * @param array        $inputs request parameters
  * @param array        $wheres 검색 조건
  * @param array        $addons 정렬 조건
  * @return void
  */
 public function make(ConfigEntity $config, array $inputs, array &$wheres, array &$addons)
 {
     $addons = [];
     $boardAddon = null;
     if (empty($inputs['orderType'])) {
         $boardAddon = $this->get($config->get('addon'));
     } else {
         $boardAddon = $this->get($inputs['addonType']);
     }
     if ($boardAddon !== null) {
         $boardAddon->make($wheres, $addons);
     } else {
         // 어떤 걸로 하면 decode 했을 때 array 가 될 수 있는걸 문자열로 넘길 수있나
         // $inputs['addonType'] 으로 $addons 를 변환 할 수 있나
     }
 }
示例#8
0
 /**
  * inputs
  *
  * @param ConfigEntity $config board config entity
  * @param array        $inputs request parameters
  * @param array        $wheres 검색 조건
  * @param array        $orders 정렬 조건
  * @return void
  */
 public function make(ConfigEntity $config, array $inputs, array &$wheres, array &$orders)
 {
     $orders = [];
     $boardOrder = null;
     if (empty($inputs['orderType'])) {
         $boardOrder = $this->get($config->get('order'));
     } else {
         $boardOrder = $this->get($inputs['orderType']);
     }
     if ($boardOrder !== null) {
         $boardOrder->make($wheres, $orders);
     } else {
         // 어떤 걸로 하면 decode 했을 때 array 가 될 수 있는걸 문자열로 넘길 수있나
         // $inputs['orderType'] 으로 $orders 를 변환 할 수 있나
     }
 }
示例#9
0
 /**
  * 전달된 rule 에 다이나믹필드 의 rule 을 추가해서 반환
  *
  * @param ConfigEntity $config board config entity
  * @param array        $rules  rule
  * @return array
  */
 public function makeRule(ConfigEntity $config, array $rules = null)
 {
     if ($rules === null) {
         $rules = $this->basic();
     }
     if ($config->get('category') === true) {
         $rules = array_merge($rules, $this->category());
     }
     // add dynamic field rule
     /** @var \Xpressengine\Config\ConfigEntity $dynamicFieldConfig */
     foreach ($this->configHandler->getDynamicFields($config) as $dynamicFieldConfig) {
         /** @var \Xpressengine\DynamicField\AbstractType $type */
         $rules = array_merge($rules, $this->dynamicField->getRules($dynamicFieldConfig));
     }
     return $rules;
 }
 /**
  * 투표 정보
  *
  * @param Request $request request
  * @return \Xpressengine\Presenter\RendererInterface
  */
 public function showVote(Request $request, $id)
 {
     // display 설정
     $display = ['assent' => true, 'dissent' => true];
     if ($this->config->get('assent') !== true) {
         $display['assent'] = false;
     }
     if ($this->config->get('dissent') !== true) {
         $display['dissent'] = false;
     }
     $user = Auth::user();
     $board = $this->handler->getModel($this->config)->find($id);
     $this->handler->setModelConfig($board, $this->config);
     $voteCounter = $this->handler->getVoteCounter();
     $vote = $voteCounter->getByName($id, $user);
     return XePresenter::makeApi(['display' => $display, 'id' => $id, 'counts' => ['assent' => $board->assentCount, 'dissent' => $board->dissentCount], 'voteAt' => $vote['counterOption']]);
 }
示例#11
0
 /**
  * 투표 정보
  *
  * @param $boardId
  * @return \Xpressengine\Presenter\RendererInterface
  */
 public function showVote($boardId)
 {
     // display 설정
     $display = ['assent' => true, 'dissent' => true];
     if ($this->config->get('assent') !== true) {
         $display['assent'] = false;
     }
     if ($this->config->get('dissent') !== true) {
         $display['dissent'] = false;
     }
     $id = Input::get('id');
     $author = Auth::user();
     $voteHandler = app('xe.board.vote');
     $counts = $voteHandler->count($id);
     $vote = $voteHandler->get($id, $author);
     return Presenter::makeApi(['display' => $display, 'id' => $id, 'counts' => $counts, 'voteAt' => $vote['counterOption']]);
 }
示例#12
0
 /**
  * 생성된 Dynamic Field revision 테이블에 데이터 입력
  *
  * @param array $args parameters
  * @return void
  */
 public function insertRevision(array $args)
 {
     if (isset($args['id']) === false) {
         throw new Exceptions\RequiredDynamicFieldException();
     }
     $insertParam = [];
     $insertParam['dynamicFieldTargetId'] = $args['id'];
     $insertParam['revisionId'] = $args['revisionId'];
     $insertParam['revisionNo'] = $args['revisionNo'];
     foreach ($this->getColumns() as $column) {
         $key = camel_case($this->config->get('id') . '_' . $column->name);
         if ($this->config->get('required') && (isset($args[$key]) === false || $args[$key] === '')) {
             throw new Exceptions\RequiredDynamicFieldException(['key' => $key]);
         }
         if (isset($args[$key])) {
             $insertParam[$key] = $args[$key];
         }
     }
     $this->handler->connection()->table($this->handler->getConfigHandler()->getRevisionTableName($this->config))->insert($insertParam);
 }
 /**
  * get database proxy options
  *
  * @param ConfigEntity $config config entity
  * @return array
  */
 public function proxyOption(ConfigEntity $config = null)
 {
     $options = [];
     if ($config != null) {
         $options['id'] = $config->get('instanceId');
     }
     return $options;
 }
示例#14
0
 /**
  * set config
  *
  * @param ConfigEntity $config document config entity
  * @param string|null  $table  table name
  * @return void
  */
 public function setConfig(ConfigEntity $config, $table = null)
 {
     $this->config = $config;
     $this->division = $config->get('division');
     $this->setProxyOptions(['id' => $config->get('instanceId'), 'group' => $config->get('group')]);
     if ($table !== null) {
         $this->table = $table;
     }
 }
示例#15
0
 /**
  * drop document instance
  *
  * @param ConfigEntity $config 현제 설정 되어 있는 config
  * @return void
  */
 protected function dropDivisionTable(ConfigEntity $config)
 {
     if ($config->get('division') === true) {
         $this->connection->getSchemaBuilder()->drop(sprintf("%s%s", $this->connection->getTablePrefix(), $this->getDivisionTableName($config)));
     }
 }
 /**
  * drop document instance
  * * ex) 게시판 삭제
  *
  * @param ConfigEntity $config 현제 설정 되어 있는 config
  * @return void
  */
 public function dropDivisionTable(ConfigEntity $config)
 {
     if ($config->get('division') === true) {
         $this->connection->delete(sprintf("DROP TABLE `%s%s`", $this->connection()->getTablePrefix(), $this->document->divisionTable($config)));
     }
 }
 /**
  * division table 이름 반환
  *
  * @param ConfigEntity $config config entity
  * @return string
  */
 public function divisionTable(ConfigEntity $config = null)
 {
     $table = $this->table;
     if ($config != null && $config->get('division') === true) {
         $table = sprintf('%s_division_%s', $this->table, $config->get('instanceId'));
     }
     return $table;
 }
示例#18
0
 /**
  * board config 에서 extension class 반환
  *
  * @param ConfigEntity $config board config entity
  * @return array
  */
 public function gets(ConfigEntity $config)
 {
     $names = $config->get('extensions');
     $classes = [];
     if (count($names) > 0) {
         foreach ($names as $name) {
             $className = '\\' . $name;
             $classes[] = new $className();
         }
     }
     return $classes;
 }
示例#19
0
 /**
  * get dynamic field config list
  *
  * @param ConfigEntity $config board config entity
  * @return array
  */
 public function getDynamicFields(ConfigEntity $config)
 {
     $configs = $this->dynamicField->gets($config->get('documentGroup'));
     if (count($configs) == 0) {
         return [];
     }
     return $configs;
 }
示例#20
0
 /**
  * create default dynamic field
  *
  * @param ConfigEntity $boardConfig board config entity
  * @deprecated
  */
 protected function createDefaultDynamicField(ConfigEntity $boardConfig)
 {
     $category = Category::create(['name' => 'board-default']);
     $config = new ConfigEntity();
     foreach (['group' => $boardConfig->get('documentGroup'), 'revision' => $boardConfig->get('revision'), 'id' => 'category', 'typeId' => 'FieldType/xpressengine@Category', 'label' => 'board::category', 'skinId' => 'FieldType/xpressengine@Category/FieldSkin/xpressengine@default', 'use' => true, 'searchable' => true, 'required' => true, 'sortable' => false, 'tableMethod' => false, 'categoryId' => $category->id, 'colorSet' => 'default', 'joinColumnName' => 'id'] as $key => $value) {
         $config->set($key, $value);
     }
     $this->dynamicField->create($config);
 }
 /**
  * 생성된 Dynamic Field 가 테이블 생성 방식인지 확인
  *
  * @param ConfigEntity $config config entity
  * @return bool
  */
 public function isTableMethodCreate(ConfigEntity $config)
 {
     return $config->get('tableMethod') === self::CREATE_TABLE_METHOD;
 }
示例#22
0
 /**
  * 복사
  *
  * @param string       $id     document id
  * @param ConfigEntity $config destination board config entity
  * @param string       $newId  new document id
  * @return void
  */
 public function copy($id, ConfigEntity $config, $newId)
 {
     if ($config === null) {
         throw new InvalidConfigException();
     }
     $item = $this->get($id);
     $item->id = $newId;
     $item->parentId = '';
     $item->instanceId = $config->get('boardId');
     $item->slug = $item->getSlug()->slug;
     $doc = $item->getDocument();
     $item = $this->makeItem($doc);
     $this->add($item, $config);
 }
 /**
  * get inserted revision data list by document id
  *
  * @param string       $id     document id
  * @param ConfigEntity $config document config entity
  * @return array
  */
 public function fetchById($id, ConfigEntity $config)
 {
     $query = $this->connection->table($this->table)->where('id', $id);
     $configs = $this->revisionManager->getHandler()->getConfigHandler()->gets($config->get('group'));
     $query = $this->revisionManager->join($configs, $query->getQuery());
     return $query->orderBy($this->table . '.revisionNo', 'desc')->get(['*', 'documents_revision.revisionId as revisionId', 'documents_revision.revisionNo as revisionNo']);
 }
示例#24
0
 /**
  * update document instance config
  * * Cannot changed 'division', 'revision' configure.
  *
  * @param ConfigEntity $config document instance config
  * @return ConfigEntity
  */
 public function put(ConfigEntity $config)
 {
     if ($this->get($config->get('instanceId')) === null) {
         throw new ConfigNotFoundException(['instanceId' => $config->get('instanceId')]);
     }
     $this->configManager->put(sprintf('%s.%s', self::CONFIG_NAME, $config->get('instanceId')), $config->getPureAll());
     return $config;
 }
示例#25
0
 /**
  * 인터셥센을 이용해 서드파티가 처리할 수 있도록 메소드 사용
  *
  * @param Builder      $query   board model query builder
  * @param Request      $request request
  * @param ConfigEntity $config  board config entity
  * @return Builder
  */
 public function makeOrder(Builder $query, Request $request, ConfigEntity $config)
 {
     $orderType = $request->get('orderType', '');
     if ($orderType === '' && $config->get('orderType') != null) {
         $orderType = $config->get('orderType', '');
     }
     if ($orderType == '') {
         $query->orderBy('head', 'desc');
     } elseif ($orderType == 'assentCount') {
         $query->orderBy('assentCount', 'desc')->orderBy('head', 'desc');
     } elseif ($orderType == 'recentlyCreated') {
         $query->orderBy(Board::CREATED_AT, 'desc')->orderBy('head', 'desc');
     } elseif ($orderType == 'recentlyUpdated') {
         $query->orderBy(Board::UPDATED_AT, 'desc')->orderBy('head', 'desc');
     }
     $query->getProxyManager()->orders($query->getQuery(), $request->all());
     return $query;
 }
 /**
  * Get activated tool's identifier for the editor
  *
  * @return array
  */
 public function getActivateToolIds()
 {
     return $this->config->get('tools', []);
 }
 /**
  * get rules by dynamic field config entity
  *
  * @param ConfigEntity $config dynamic field config entity
  * @return array
  */
 public function getRules(ConfigEntity $config)
 {
     // 필수 입력이 아니면 처리하지 않음
     if ($config->get('required') === false) {
         return [];
     }
     $type = $this->getByConfig($config);
     $rules = [];
     foreach ($type->getRules() as $columnName => $rule) {
         $key = camel_case($config->get('id') . '_' . $columnName);
         $rules[$key] = $rule;
     }
     return $rules;
 }
 /**
  * update document instance config
  * * division, revision 설정 변경 불가.
  *      - 이 설정에 대한 변경은 core 에서 제공 안함.
  *
  * @param ConfigEntity $config document instance config
  * @return ConfigEntity
  */
 public function put(ConfigEntity $config)
 {
     if ($this->get($config->get('instanceId')) === null) {
         throw new Exceptions\ConfigException();
     }
     $diff = $config->diff();
     if (isset($diff['instanceId']) === null) {
         throw new Exceptions\ConfigException();
     }
     $this->configManager->put(sprintf('%s.%s', self::CONFIG_NAME, $config->get('instanceId')), $config->getPureAll());
     return $config;
 }
 /**
  * get type by dynamic field config entity
  *
  * @param ConfigEntity $config dynamic field config entity
  * @return AbstractType
  */
 public function getByConfig(ConfigEntity $config)
 {
     $type = $this->registerHandler->getType($this, $config->get('typeId'));
     $type->setConfig($config);
     $skin = $this->registerHandler->getSkin($this, $config->get('skinId'));
     $skin->setConfig($config);
     $type->setSkin($skin);
     return $type;
 }
 /**
  * drop document instance
  *
  * @param ConfigEntity $config 현제 설정 되어 있는 config
  * @return void
  */
 protected function dropDivisionTable(ConfigEntity $config)
 {
     if ($config->get('division') === true) {
         $this->connection->getSchemaBuilder()->drop($this->getDivisionTableName($config));
     }
 }