• Модуль: landing
  • Путь к файлу: ~/bitrix/modules/landing/lib/publicaction/repo.php
  • Класс: BitrixLandingPublicActionRepo
  • Вызов: Repo::unregister
static function unregister($code)
{
	$result = new PublicActionResult();
	$error = new BitrixLandingError;

	$result->setResult(false);

	if (!is_string($code))
	{
		return $result;
	}

	// search and delete
	if ($code)
	{
		// set app code
		$app = BitrixLandingPublicAction::restApplication();

		$row = RepoCore::getList(array(
			'select' => array(
				'ID'
			),
			'filter' =>
				isset($app['CODE'])
				? array(
					'=XML_ID' => $code,
					'=APP_CODE' => $app['CODE']
				)
				: array(
					'=XML_ID' => $code
				)
		))->fetch();
		if ($row)
		{
			// delete all sush blocks from landings
			$codeToDelete = array();
			$res = RepoCore::getList(array(
				'select' => array(
					'ID'
				),
				'filter' =>
					isset($app['CODE'])
					? array(
						'=XML_ID' => $code,
						'=APP_CODE' => $app['CODE']
					)
					: array(
						'=XML_ID' => $code
					)
			));
			while ($rowRepo = $res->fetch())
			{
				$codeToDelete[] = 'repo_' . $rowRepo['ID'];
			}
			if (!empty($codeToDelete))
			{
				BlockCore::deleteByCode($codeToDelete);
			}
			// delete block from repo
			$res = RepoCore::delete($row['ID']);
			if ($res->isSuccess())
			{
				$result->setResult(true);
			}
			else
			{
				$error->addFromResult($res);
			}
		}
	}

	$result->setError($error);

	return $result;
}