Base::onBeforeAction

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. Base
  4. onBeforeAction
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/controller/filter/factory.php
  • Класс: Bitrix\Crm\Controller\Filter\Factory
  • Вызов: Factory::onBeforeAction
public function onBeforeAction(Event $event)
{
	$entityTypeId = (int)($this->getAction()->getController()->getRequest()->get('entityTypeId') ?? 0);
	if ($entityTypeId <= 0 && Loader::includeModule('rest'))
	{
		$restData = \CRestUtil::getRequestData();
		$entityTypeId = (int)($restData['entityTypeId'] ?? 0);
	}
	$factory = Container::getInstance()->getFactory($entityTypeId);

	if ($factory)
	{
		$controller = $this->getAction()->getController();
		if ($controller instanceof FactoryInjectable)
		{
			$controller->setFactory($factory);
		}
	}
	else
	{
		$this->addError(new Error(
			Loc::getMessage('CRM_TYPE_TYPE_NOT_FOUND'),
			ErrorCode::NOT_FOUND)
		);
	}

	return new EventResult(
		$this->errorCollection->isEmpty() ? EventResult::SUCCESS : EventResult::ERROR,
		null,
		null,
		$this
	);
}

Добавить комментарий