- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/lib/item.php
- Класс: BitrixTasksItem
- Вызов: Item::offsetGet
public function offsetGet($offset)
{
$map = $this->getMap();
$value = null;
$isImmutable = $this->isImmutable();
/** @var FieldScalar $field */
$field = $map[$offset];
if($field)
{
if(!$this->readingFailed)
{
// offset is in the cache (values), null-ed or not, but it presents there
if($this->containsKey($offset))
{
return $field->getValue($offset, $this);
}
// if the record exists, try to download value from database
if($this->id)
{
$isTabletOrUf = $field->isSourceTablet() || $field->isSourceUserField();
if($isTabletOrUf)
{
if($this->fetchInProgress) // can not go to the endless recursion, sorry...
{
return null;
}
$this->fetchInProgress = true;
}
$tabletLoaded = $this->isTabletLoaded();
// temporarily disable immutable flag, to allow offsetSet
if($isImmutable)
{
$this->immutable = false;
}
// if this is a tablet field, get all tablet (base) data
if($field->isSourceTablet())
{
$this->fetchDataAndCache(!$tabletLoaded, false);
}
// the same behaviour is for user field, but get both tablet (base) and user field data
elseif($field->isSourceUserField())
{
$this->fetchDataAndCache(!$tabletLoaded, !$this->setUFLoaded());
}
// for other types - get just tablet (base) data
else
{
$this->fetchDataAndCache(!$tabletLoaded, false);
}
// restore flag
if($isImmutable)
{
$this->immutable = true;
}
if($isTabletOrUf)
{
$this->fetchInProgress = false;
}
}
if(!$this->readingFailed) // still no error after download
{
$value = $field->getValue($offset, $this);
}
}
}
else
{
// we are beyond the map scope, but this field obviously was set manually
$value = $this->offsetGetDirect($offset);
}
return $value;
}