public static function findById($id)
{
if (!$id || strlen($id) != 24) {
return null;
}
$instance = static::entity()->get(get_called_class(), $id);
if ($instance) {
return $instance;
}
$mongo = static::entity()->getDatabase();
$data = $mongo->findOne(static::$entityCollection, ['_id' => $mongo->id($id)]);
if (!$data) {
return null;
}
$instance = new static();
$data['__webiny_db__'] = true;
$instance->populate($data);
return static::entity()->add($instance);
}