64 lines
2.2 KiB
PHP
64 lines
2.2 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
|
|
{
|
|
public function __construct(TrafficModel $model)
|
|
{
|
|
parent::__construct($model);
|
|
$this->addClassPaths('Traffic');
|
|
}
|
|
public function getFormService(): TrafficForm
|
|
{
|
|
if ($this->formServiceInstance === null) {
|
|
$this->formServiceInstance = new TrafficForm();
|
|
$this->formServiceInstance->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->formServiceInstance;
|
|
}
|
|
public function getHelper(): TrafficHelper
|
|
{
|
|
if ($this->helperInstance === null) {
|
|
$this->helperInstance = new TrafficHelper();
|
|
$this->helperInstance->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->helperInstance;
|
|
}
|
|
//기본 기능부분
|
|
public function create(object $dto): TrafficEntity
|
|
{
|
|
if (!$dto instanceof TrafficDTO) {
|
|
throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다.");
|
|
}
|
|
return parent::create($dto);
|
|
}
|
|
public function modify($uid, object $dto): TrafficEntity
|
|
{
|
|
if (!$dto instanceof TrafficDTO) {
|
|
throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다.");
|
|
}
|
|
return parent::modify($uid, $dto);
|
|
}
|
|
//List 검색용
|
|
}
|