• Модуль: iblock
  • Путь к файлу: ~/bitrix/modules/iblock/lib/template/entity/element.php
  • Класс: BitrixIblockTemplateEntityElement
  • Вызов: Element::setFields
public function setFields(array $fields)
{
	parent::setFields($fields);
	if (
		is_array($this->fields)
		&& $this->fields["IBLOCK_ID"] > 0
	)
	{
		if (
			isset($fields["PROPERTY_VALUES"])
			&& is_array($fields["PROPERTY_VALUES"])
		)
		{
			$this->property = new ElementProperty($this->id);
			$this->property->setIblockId($this->fields["IBLOCK_ID"]);
			$this->property->setFields($fields["PROPERTY_VALUES"]);
		}

		$this->iblock = new Iblock($fields["IBLOCK_ID"]);

		if (
			isset($fields["IBLOCK_SECTION_ID"])
			&& $fields["IBLOCK_SECTION_ID"] > 0
		)
		{
			$this->parent = new Section($fields["IBLOCK_SECTION_ID"]);
			$this->sections = new SectionPath($fields["IBLOCK_SECTION_ID"]);
		}
		elseif (
			isset($fields["IBLOCK_SECTION"])
			&& is_array($fields["IBLOCK_SECTION"])
		)
		{
			$section = -1;
			foreach ($fields["IBLOCK_SECTION"] as $sectionId)
			{
				if ($sectionId > 0)
				{
					if ($section < 0 || $section > $sectionId)
						$section = $sectionId;
				}
			}

			if ($section > 0)
			{
				$this->parent = new Section($section);
				$this->sections = new SectionPath($section);
			}
		}

		if (BitrixMainLoader::includeModule('catalog'))
			$this->catalog = new ElementCatalog($this->id);
	}
}