• Модуль: documentgenerator
  • Путь к файлу: ~/bitrix/modules/documentgenerator/lib/controller/base.php
  • Класс: BitrixDocumentGeneratorControllerBase
  • Вызов: Base::getAutoWiredParameters
public function getAutoWiredParameters(Controller $controller = null)
{
	return [
		new ExactParameter(
			BitrixDocumentGeneratorDocument::class,
			'document',
			function($className, $id) use ($controller) {
				if (!$controller)
				{
					$controller = $this;
				}
				/** @var BitrixDocumentGeneratorDocument $className */
				$document = $className::loadById((int)$id);
				if (!$document)
				{
					$controller->addError(
						new Error(
							Loc::getMessage('DOCGEN_CONTROLLER_DOCUMENT_NOT_FOUND_ERROR')
						)
					);
				}

				return $document;
			}
		),
		new ExactParameter(
			BitrixDocumentGeneratorTemplate::class,
			'template',
			function($className, $id) use ($controller) {
				if (!$controller)
				{
					$controller = $this;
				}
				/** @var BitrixDocumentGeneratorTemplate $className */
				$template = $className::loadById($id);
				if (!$template)
				{
					$controller->addError(
						new Error(
							Loc::getMessage('DOCGEN_CONTROLLER_TEMPLATE_NOT_FOUND_ERROR')
						)
					);
				}

				return $template;
			}
		),
		new ExactParameter(
			BitrixDocumentGeneratorTemplate::class,
			'template',
			function($className, $templateId) use ($controller) {
				if (!$controller)
				{
					$controller = $this;
				}
				/** @var BitrixDocumentGeneratorTemplate $className */
				$template = $className::loadById($templateId);
				if (!$template)
				{
					$controller->addError(
						new Error(
							Loc::getMessage('DOCGEN_CONTROLLER_TEMPLATE_NOT_FOUND_ERROR')
						)
					);
				}

				return $template;
			}
		),
		new ExactParameter(
			BitrixDocumentGeneratorModelRole::class,
			'role',
			function($className, $id)
			{
				return RoleTable::getById($id)->fetchObject();
			}
		),
		new ExactParameter(
			BitrixMainNumeratorNumerator::class,
			'numerator',
			function($className, $id)
			{
				/** @var BitrixMainNumeratorNumerator $className */
				return $className::load($id);
			}
		),
	];
}