dbmsv4/app/Services/Equipment/LineService.php
2026-02-24 11:05:05 +09:00

59 lines
1.9 KiB
PHP

<?php
namespace App\Services\Equipment;
use App\Entities\Equipment\LineEntity;
use App\Forms\Equipment\LineForm;
use App\Helpers\Equipment\LineHelper;
use App\Models\Equipment\LineModel;
use App\Traits\UtilTrait;
use RuntimeException;
class LineService extends EquipmentService
{
use UtilTrait;
protected string $formClass = LineForm::class;
protected string $helperClass = LineHelper::class;
public function __construct(LineModel $model)
{
parent::__construct($model);
$this->addClassPaths('Line');
}
public function getEntityClass(): string
{
return LineEntity::class;
}
//기본 기능부분
protected function getEntity_process(mixed $entity): LineEntity
{
return $entity;
}
protected function create_process(array $formDatas): LineEntity
{
if (!$this->isValidCIDRTrait($formDatas['bandwith'])) {
throw new \Exception("{$formDatas['bandwith']}는 CIDR 형식에 부합되지 않습니다.");
}
//Line 등록
$entity = parent::create_process($formDatas);
if (!$entity instanceof LineEntity) {
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생:Return Type은 LineEntity만 가능");
}
//자동추가용
// 1. 기존 설정값 저장 (나중에 복구하기 위함)
$originalTime = ini_get('max_execution_time');
// 2. 이 함수를 위해 시간 늘리기 (예: 5분)
set_time_limit(300);
//IP등록
foreach ($this->cidrToIpRangeTrait($entity->getBandwith()) as $ip) {
service('part_ipservice')->attachToLine($entity, $ip);
}
// 3. 작업 완료 후 기존 설정으로 복구 (선택 사항)
set_time_limit($originalTime);
return $entity;
}
//List 검색용
//FormFilter 조건절 처리
//검색어조건절처리
}