48 lines
1.5 KiB
PHP
48 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Backend;
|
|
|
|
use App\Models\BoardModel;
|
|
use App\Entities\BoardEntity;
|
|
use App\Models\BoardConfigModel;
|
|
|
|
class BoardBackend extends BaseHierarchyBackend
|
|
{
|
|
private $_board_config_uids = null;
|
|
private $_boardConfigModel = null;
|
|
public function __construct()
|
|
{
|
|
parent::__construct('Board');
|
|
$this->_model = new BoardModel();
|
|
}
|
|
//BoardConfig모델
|
|
final public function getBoardConfigModel(): BoardConfigModel
|
|
{
|
|
return is_null($this->_boardConfigModel) ? new BoardConfigModel() : $this->_boardConfigModel;
|
|
}
|
|
|
|
//Field별 Form Option용
|
|
public function getFieldFormOption(string $field): array
|
|
{
|
|
switch ($field) {
|
|
case 'board_config_uid':
|
|
$options = $this->_board_config_uids = $this->_board_config_uids ?: $this->getBoardConfigModel()->getFieldFormOptions(['status' => 'use']);
|
|
break;
|
|
default:
|
|
return parent::getFieldFormOption($field);
|
|
break;
|
|
}
|
|
if (!is_array($options)) {
|
|
throw new \Exception(__FUNCTION__ . "에서 {$this->getClassName()}의 Field:{$field}의 FormOptionData가 array가 아닙니다.\n" . var_export($options, true));
|
|
}
|
|
return $options;
|
|
}
|
|
//View관련
|
|
public function view($entity)
|
|
{
|
|
// view_cnt에 추가하기위함
|
|
$this->_model->increaseViewCount($entity->getPrimaryKey());
|
|
return parent::view($entity);
|
|
}
|
|
}
|