<?php

namespace App\Services\Equipment;

use RuntimeException;
use App\Models\Equipment\LineModel;
use App\Helpers\Equipment\LineHelper;
use App\Forms\Equipment\LineForm;
use App\Entities\Equipment\LineEntity;
use App\Entities\CommonEntity;
use App\DTOs\Equipment\LineDTO;

class LineService extends EquipmentService
{
    private $_form = null;
    private $_helper = null;
    public function __construct(LineModel $model)
    {
        parent::__construct($model);
        $this->addClassPaths('Line');
    }
    public function getDTOClass(): string
    {
        return LineDTO::class;
    }
    public function createDTO(array $formDatas): LineDTO
    {
        return new LineDTO($formDatas);
    }
    public function getEntityClass(): string
    {
        return LineEntity::class;
    }
    public function getFormService(): LineForm
    {
        if ($this->_form === null) {
            $this->_form = new LineForm();
            $this->_form->setAttributes([
                'pk_field'         =>  $this->getPKField(),
                'title_field'      => $this->getTitleField(),
                'table'            => $this->model->getTable(),
                'useAutoIncrement' => $this->model->useAutoIncrement(),
                'class_path' => $this->getClassPaths(false)
            ]);
        }
        return $this->_form;
    }
    public function getHelper(): LineHelper
    {
        if ($this->_helper === null) {
            $this->_helper = new LineHelper();
            $this->_helper->setAttributes([
                'pk_field'         =>  $this->getPKField(),
                'title_field'      => $this->getTitleField(),
                'table'            => $this->model->getTable(),
                'useAutoIncrement' => $this->model->useAutoIncrement(),
                'class_path' => $this->getClassPaths(false)
            ]);
        }
        return $this->_helper;
    }
    //기본 기능부분
    protected function getEntity_process(mixed $entity): LineEntity
    {
        return $entity;
    }
    //List 검색용
    //FormFilter 조건절 처리
    //검색어조건절처리
}
