82 lines
2.7 KiB
PHP
82 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use App\DTOs\TrafficDTO;
|
|
use App\Entities\TrafficEntity;
|
|
use App\Forms\TrafficForm;
|
|
use App\Helpers\TrafficHelper;
|
|
use App\Models\TrafficModel;
|
|
use RuntimeException;
|
|
|
|
class TrafficService extends CommonService
|
|
{
|
|
private $_form = null;
|
|
private $_helper = null;
|
|
public function __construct(TrafficModel $model)
|
|
{
|
|
parent::__construct($model);
|
|
$this->addClassPaths('Traffic');
|
|
}
|
|
public function createDTO(array $formDatas): TrafficDTO
|
|
{
|
|
return new TrafficDTO($formDatas);
|
|
}
|
|
public function getFormService(): TrafficForm
|
|
{
|
|
if ($this->_form === null) {
|
|
$this->_form = new TrafficForm();
|
|
$this->_form->setAttributes([
|
|
'pk_field' => $this->model->getPKField(),
|
|
'title_field' => $this->model->getTitleField(),
|
|
'table' => $this->model->getTable(),
|
|
'useAutoIncrement' => $this->model->useAutoIncrement(),
|
|
'class_path' => $this->getClassPaths(false)
|
|
]);
|
|
}
|
|
return $this->_form;
|
|
}
|
|
public function getHelper(): TrafficHelper
|
|
{
|
|
if ($this->_helper === null) {
|
|
$this->_helper = new TrafficHelper();
|
|
$this->_helper->setAttributes([
|
|
'pk_field' => $this->model->getPKField(),
|
|
'title_field' => $this->model->getTitleField(),
|
|
'table' => $this->model->getTable(),
|
|
'useAutoIncrement' => $this->model->useAutoIncrement(),
|
|
'class_path' => $this->getClassPaths(false)
|
|
]);
|
|
}
|
|
return $this->_helper;
|
|
}
|
|
//기본 기능부분
|
|
protected function getEntity_process(mixed $entity): TrafficEntity
|
|
{
|
|
return $entity;
|
|
}
|
|
protected function create_process(array $formDatas): TrafficEntity
|
|
{
|
|
return new TrafficEntity($formDatas);
|
|
}
|
|
public function create(object $dto): TrafficEntity
|
|
{
|
|
if (!$dto instanceof TrafficDTO) {
|
|
throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다.");
|
|
}
|
|
return parent::create($dto);
|
|
}
|
|
protected function modify_process($uid, array $formDatas): TrafficEntity
|
|
{
|
|
return parent::modify_process($uid, $formDatas);
|
|
}
|
|
public function modify($uid, object $dto): TrafficEntity
|
|
{
|
|
if (!$dto instanceof TrafficDTO) {
|
|
throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다.");
|
|
}
|
|
return parent::modify($uid, $dto);
|
|
}
|
|
//List 검색용
|
|
}
|