- Модуль: transformer
- Путь к файлу: ~/bitrix/modules/transformer/lib/filetransformer.php
- Класс: BitrixTransformerFileTransformer
- Вызов: FileTransformer::transform
public function transform($file, $formats, $module, $callback, $params = array())
{
$result = new Result();
if(empty($formats))
{
$result->addError(new Error('Formats is empty'));
}
$foundFile = new File($file);
$publicPath = $foundFile->getPublicPath();
if(empty($publicPath))
{
$result->addError(new Error('File '.$file.' not found'));
}
$fileSize = $foundFile->getSize();
if(!empty($fileSize) && $fileSize > static::MAX_FILESIZE)
{
$result->addError(new Error($this->getFileTypeName().' is too big'));
}
if(!$result->isSuccess())
{
Log::write($result->getErrorMessages());
return $result;
}
$params['file'] = $publicPath;
$params['fileSize'] = $fileSize;
$params['formats'] = $formats;
$command = new Command($this->getCommandName(), $params, $module, $callback);
$result = $command->save();
if($result->isSuccess())
{
$http = new Http();
$result = $command->send($http);
self::clearInfoCache($file);
}
return $result;
}