- Модуль: vote
- Путь к файлу: ~/bitrix/modules/vote/lib/base/baseobject.php
- Класс: BitrixVoteBaseBaseObject
- Вызов: BaseObject::loadFromId
static function loadFromId($id, $shouldBeNewIfIdIsNull = false)
{
if (empty(self::$objectStorage))
{
register_shutdown_function([__CLASS__, "shutdown"]);
}
$obj = null;
$c = get_called_class();
$innerId = $id = intval($id);
if (!array_key_exists($c, self::$objectStorage))
{
self::$objectStorage[$c] = ["maxId" => 0, "data" => []];
}
if ($shouldBeNewIfIdIsNull === true && $id <= 0)
{
$innerId = implode("", ["n", self::$objectStorage[$c]["maxId"]++]);
}
if (array_key_exists($innerId, self::$objectStorage[$c]["data"]))
{
$obj = self::$objectStorage[$c]["data"][$innerId];
}
if ($obj === null)
{
$obj = new $c($id);
self::$objectStorage[$c]["data"][$innerId] = $obj;
}
return $obj;
}