daemon-idc init

This commit is contained in:
최준흠 2026-02-26 09:07:48 +09:00
parent f470a44f40
commit a8b50340ac

View File

@ -13,6 +13,7 @@ abstract class CommonEntity extends Entity
* 엔티티에서 "빈문자/공백 입력은 NULL로 저장"해야 하는 필드 목록. * 엔티티에서 "빈문자/공백 입력은 NULL로 저장"해야 하는 필드 목록.
* 기본은 배열이고, Entity에서 필요한 것만 override해서 채우면 . * 기본은 배열이고, Entity에서 필요한 것만 override해서 채우면 .
*/ */
protected array $nullableFields = [];
public function __construct(array|null $data = null) public function __construct(array|null $data = null)
{ {
parent::__construct($data); parent::__construct($data);
@ -33,8 +34,21 @@ abstract class CommonEntity extends Entity
final public function __set(string $key, $value = null) final public function __set(string $key, $value = null)
{ {
if (array_key_exists($key, $this->attributes)) { if (array_key_exists($key, $this->attributes)) {
return $this->attributes[$key] = $value;
// 이 엔티티에서 NULL로 보정할 필드만 처리 (화이트리스트)
if (!empty($this->nullableFields) && in_array($key, $this->nullableFields, true)) {
if (is_string($value)) {
$value = trim($value);
}
$this->attributes[$key] = ($value === '' || $value === null) ? null : $value;
return;
}
// 기본: 그대로 저장
$this->attributes[$key] = $value;
return;
} }
parent::__set($key, $value); parent::__set($key, $value);
} }
@ -50,11 +64,6 @@ abstract class CommonEntity extends Entity
return $this->attributes[$field] ?? ""; return $this->attributes[$field] ?? "";
} }
public function getCustomTitle(): string
{
return $this->getTitle();
}
final public function getStatus(): string final public function getStatus(): string
{ {
return $this->attributes['status'] ?? ""; return $this->attributes['status'] ?? "";
@ -74,4 +83,9 @@ abstract class CommonEntity extends Entity
{ {
return $this->attributes['deleted_at'] ?? ""; return $this->attributes['deleted_at'] ?? "";
} }
public function getCustomTitle(): string
{
return $this->getTitle();
}
} }