• Модуль: iblock
  • Путь к файлу: ~/bitrix/modules/iblock/lib/inheritedproperty/basetemplate.php
  • Класс: BitrixIblockInheritedPropertyBaseTemplate
  • Вызов: BaseTemplate::set
public function set(array $templates)
{
	$templateList = BitrixIblockInheritedPropertyTable::getList(array(
		"select" => array("ID", "CODE", "TEMPLATE"),
		"filter" => array(
			"=IBLOCK_ID" => $this->entity->getIblockId(),
			"=ENTITY_TYPE" => $this->entity->getType(),
			"=ENTITY_ID" => $this->entity->getId(),
		),
	));
	array_map("trim", $templates);
	while ($row = $templateList->fetch())
	{
		$CODE = $row["CODE"];
		if (array_key_exists($CODE, $templates))
		{
			if ($templates[$CODE] !== $row["TEMPLATE"])
			{
				if ($templates[$CODE] != "")
					BitrixIblockInheritedPropertyTable::update($row["ID"], array(
						"TEMPLATE" => $templates[$CODE],
					));
				else
					BitrixIblockInheritedPropertyTable::delete($row["ID"]);

				$this->entity->deleteValues($row["ID"]);
			}
			unset($templates[$CODE]);
		}
	}

	if (!empty($templates))
	{
		foreach ($templates as $CODE => $TEMPLATE)
		{
			if ($TEMPLATE != "")
			{
				BitrixIblockInheritedPropertyTable::add(array(
					"IBLOCK_ID" => $this->entity->getIblockId(),
					"CODE" => $CODE,
					"ENTITY_TYPE" => $this->entity->getType(),
					"ENTITY_ID" => $this->entity->getId(),
					"TEMPLATE" => $TEMPLATE,
				));
			}
		}
		$this->entity->clearValues();
	}
}