93 lines
2.5 KiB
PHP
93 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Libraries\Mangboard;
|
|
|
|
|
|
use App\Libraries\MyStorage\FileLibrary as ParentLibrary;
|
|
use App\Models\Mangboard\FileModel;
|
|
use App\Entities\Mangboard\UserEntity;
|
|
use App\Entities\Mangboard\FileEntity;
|
|
|
|
class FileLibrary extends ParentLibrary
|
|
{
|
|
private $_user = null;
|
|
private $_boardName = "";
|
|
private $_boardTable = "";
|
|
private $_model = null;
|
|
public function __construct(string $path)
|
|
{
|
|
parent::__construct($path);
|
|
}
|
|
public function getModel(): FileModel
|
|
{
|
|
if ($this->_model === null) {
|
|
return $this->_model = new FileModel();
|
|
}
|
|
return $this->_model;
|
|
}
|
|
|
|
//override
|
|
public function getEntity(): FileEntity
|
|
{
|
|
if ($this->_entity === null) {
|
|
$this->_entity = new FileEntity();
|
|
$this->_entity->setPath($this->getPath());
|
|
}
|
|
return $this->_entity;
|
|
}
|
|
|
|
public function getUser(): UserEntity
|
|
{
|
|
if ($this->_user === null) {
|
|
throw new \Exception("사용자정보가 없습니다.");
|
|
}
|
|
return $this->_user;
|
|
}
|
|
public function setUser(UserEntity $user): void
|
|
{
|
|
$this->_user = $user;
|
|
}
|
|
public function getBoardName(): string
|
|
{
|
|
if ($this->_boardName === null) {
|
|
throw new \Exception("BoardModel이 지정되지 않았습니다.");
|
|
}
|
|
return $this->_boardName;
|
|
}
|
|
public function setBoardName(string $boardName): void
|
|
{
|
|
$this->_boardName = $boardName;
|
|
}
|
|
public function getBoardTable(): string
|
|
{
|
|
if ($this->_boardTable === null) {
|
|
throw new \Exception("BoardModel이 지정되지 않았습니다.");
|
|
}
|
|
return $this->_boardTable;
|
|
}
|
|
public function setBoardTable(string $boardTable): void
|
|
{
|
|
$this->_boardTable = $boardTable;
|
|
}
|
|
|
|
public function save($content): null|FileEntity
|
|
{
|
|
//망보드 파일관리 table에 등록
|
|
try {
|
|
$entity = parent::save($content);
|
|
if ($entity === null) {
|
|
return null;
|
|
}
|
|
$entity->user_pid = $this->getUser()->getPK();
|
|
$entity->user_name = $this->getUser()->getTitle();
|
|
$entity->board_name = $this->getBoardName();
|
|
$entity->table_name = $this->getBoardTable();
|
|
$entity->reg_date = date("Y-m-d H:i:s");
|
|
return $this->getModel()->create($entity);
|
|
} catch (\Exception $e) {
|
|
log_message("error", $e->getMessage());
|
|
return null;
|
|
}
|
|
}
|
|
}
|