- Модуль: ui
- Путь к файлу: ~/bitrix/modules/ui/lib/controller/fileuploader.php
- Класс: BitrixUIControllerFileUploader
- Вызов: FileUploader::getAutoWiredParameters
public function getAutoWiredParameters(): array
{
$request = $this->getRequest();
return [
new ExactParameter(
UploaderController::class,
'controller',
function ($className, string $controller, string $controllerOptions = null) {
try
{
$options = empty($controllerOptions) ? [] : Json::decode($controllerOptions);
$options = is_array($options) ? $options : [];
}
catch (Exception $e)
{
$options = [];
}
if (is_subclass_of($this, FileUploader::class))
{
$availableControllers = $this->getAvailableControllers();
if ($availableControllers === null)
{
$this->addError(new Error(
'You have to override "getAvailableControllers" method for your custom ajax controller.'
));
return null;
}
[$moduleId, $className] = ControllerResolver::resolveName($controller);
$className = strtolower(ltrim($className, '\'));
$availableNames = array_map(function($name) {
return strtolower(ltrim($name, '\'));
}, $availableControllers);
if (
!in_array(strtolower($controller), $availableNames)
&& !in_array($className, $availableNames)
)
{
$this->addError(new Error('Invalid Controller Name.'));
return null;
}
}
return ControllerResolver::createController($controller, $options);
}
),
new Parameter(
Chunk::class,
function ($className) use ($request) {
$result = Chunk::createFromRequest($request);
if ($result->isSuccess())
{
return $result->getData()['chunk'];
}
else
{
$this->addErrors($result->getErrors());
return null;
}
}
),
];
}