Automation/app/Libraries/Mangboard/BoardsLibrary.php
2024-09-15 16:02:23 +09:00

49 lines
1.3 KiB
PHP

<?php
namespace App\Libraries\Mangboard;
use App\Libraries\CommonLibrary;
use App\Models\Mangboard\BoardsModel;
use App\Entities\Mangboard\UserEntity;
use App\Entities\Mangboard\BoardsEntity;
class BoardsLibrary extends CommonLibrary
{
private $_model = null;
private $_entity = null;
private $_category = null;
private $_user_entity = null;
public function __construct(string $category, UserEntity $uer_entity)
{
parent::__construct();
$this->_category = $category;
$this->_user_entity = $uer_entity;
}
public function getModel(): BoardsModel
{
if ($this->_model === null) {
$this->_model = new BoardsModel();
}
return $this->_model;
}
public function getEntity(): BoardsEntity
{
if ($this->_entity === null) {
$this->_entity = $this->getModel()->getEntityByID("board_" . $this->getCategory());
}
return $this->_entity;
}
//---------------------------------------------------------------------//
public function getCategory(): string
{
return $this->_category;
}
public function getUserEntity(): UserEntity
{
if ($this->_user_entity === null) {
throw new \Exception("사용자정보가 없습니다.");
}
return $this->_user_entity;
}
}