22 return static::get(
$type, $id);
27 return static::get(
$type, internalObject: $internalObject);
33 if ($entityType ===
null)
38 $config = static::getClassAndModule($entityType);
45 if (!Loader::includeModule($module))
50 if ($internalObject !==
null && static::hasGetIdMethod($internalObject))
52 $id = (int)$internalObject->getId();
55 if ($id ===
null || $id <= 0)
62 return new $class($id);
64 catch (ObjectException)
70 private static function hasGetIdMethod(mixed $internalObject): bool
72 if (!is_object($internalObject))
77 $reflection =
new ReflectionClass($internalObject);
79 return $reflection->hasMethod(
'getId') && $reflection->getMethod(
'getId')->isPublic();
86 EntityType::Task => [TaskEntity::class,
'tasks'],
87 EntityType::CalendarSection => [SectionEntity::class,
'calendar'],
88 EntityType::CalendarEvent => [EventEntity::class,
'calendar'],
89 EntityType::Comment => [CommentEntity::class,
'forum'],
90 EntityType::File => [FileEntity::class,
'disk'],
91 EntityType::TaskCheckList => [TaskCheckListEntity::class,
'tasks'],