BaseFile
in package
implements
IFile
Class BaseFile
Tags
Interfaces, Classes and Traits
- IFile
- Interface IFile
Table of Contents
- MAX_FILES_DIR = 100
- Максимальное кол-во файлов в одной директории
- PERMITTED_CHARS = '0123456789_abcdefghijklmnopqrstuvwxyz'
- $add_dt : mixed
- $content_type : mixed
- $file_name : mixed
- $id : mixed
- $new_dir : mixed
- $new_file_name : mixed
- $old_dir : mixed
- $old_file_name : mixed
- $original_name : mixed
- $size : mixed
- $sub_dir : mixed
- $uuid : mixed
- $database : Context
- $primary_key : mixed
- $props : mixed
- $table : mixed
- $table_tags_files : mixed
- $tempName : mixed
- $upload_dir : mixed
- __construct() : mixed
- createDir() : bool
- Создает директорию
- delete() : bool
- Удаляет файл
- get() : $this|bool
- getChildDir() : array<string|int, mixed>
- Возвращает массив дочерних директорий
- getPath() : bool|string
- Возвращает путь до файла
- isEmpty() : bool
- Проверяет директорию на пустоту
- move() : static
- Moves an uploaded file to a new location. If the destination file already exists, it will be overwritten.
- save() : $this
- Метод сохраняет файл и регистрирует его в таблице файлов (files).
- setAddDt() : mixed
- Задаёт дату добавления, на текущий момент
- setContentType() : $this|false
- Задаёт тип файла
- setFileName() : $this|false
- Задаёт имя файлу
- setOriginalName() : $this|false
- Задаёт оригинальное имя
- setSize() : $this|false
- Задаёт размер файла
- setSubDir() : $this
- Задаёт расположение
- setUuid() : $this
- Задаёт uuid файла
- absoluteResizeDir() : string
- absoluteUploadDir() : string
- add() : $this|bool
- relativeResizeDir() : string
- relativeUploadDir() : string
- replace() : $this|bool
- update() : $this|false
- validate() : bool
- __buildFileArray() : array<string|int, mixed>
- Строит массив атрибутов файла
- __changeDir() : mixed
- *
- __checkMaxCountFilesDir() : bool
- Проверяет заполнена ли директори
- __deleteOld() : bool
- __findDirToSave() : mixed|string
- Выполняет поиск подходящей директории для сохранения файла.
- __genOnlyDirName() : string
- Создает уникальное имя директории
- __genOnlyFileName() : bool|string
- Создает уникальное имя файла в указанной директории
- __prepareDirToSave() : false|mixed|string
- __prepareSysDir() : bool
- __rename() : void
- переименовывает файл
- callManager() : FileManager
- Возвращает экземпляр класса FileManager
- getPropsToArray() : array<string|int, mixed>
- Преобразует свойства файла в массив
- setProps() : mixed
- Сохраняет свойство файла в объект
Constants
MAX_FILES_DIR
Максимальное кол-во файлов в одной директории
public
mixed
MAX_FILES_DIR
= 100
PERMITTED_CHARS
public
mixed
PERMITTED_CHARS
= '0123456789_abcdefghijklmnopqrstuvwxyz'
Properties
$add_dt
public
mixed
$add_dt
$content_type
public
mixed
$content_type
$file_name
public
mixed
$file_name
$id
public
mixed
$id
$new_dir
public
mixed
$new_dir
$new_file_name
public
mixed
$new_file_name
$old_dir
public
mixed
$old_dir
$old_file_name
public
mixed
$old_file_name
$original_name
public
mixed
$original_name
$size
public
mixed
$size
$sub_dir
public
mixed
$sub_dir
$uuid
public
mixed
$uuid
$database
private
Context
$database
$primary_key
private
mixed
$primary_key
= 'id'
$props
private
mixed
$props
= array('file_name', 'sub_dir', 'content_type', 'size', 'original_name', 'uuid', 'add_dt')
$table
private
mixed
$table
= 'files'
$table_tags_files
private
mixed
$table_tags_files
= 'tags_files'
$tempName
private
mixed
$tempName
$upload_dir
private
mixed
$upload_dir
Methods
__construct()
public
__construct(mixed $upload_dir, Context $database) : mixed
Parameters
- $upload_dir : mixed
- $database : Context
Return values
mixed —createDir()
Создает директорию
public
createDir( $path[, int $mode = 755 ][, bool $recursive = true ]) : bool
Parameters
Tags
Return values
bool —delete()
Удаляет файл
public
delete() : bool
Tags
Return values
bool —get()
public
get(int $file_id) : $this|bool
Parameters
- $file_id : int
Tags
Return values
$this|bool —getChildDir()
Возвращает массив дочерних директорий
public
getChildDir( $path) : array<string|int, mixed>
Parameters
Return values
array<string|int, mixed> —getPath()
Возвращает путь до файла
public
getPath() : bool|string
Return values
bool|string —isEmpty()
Проверяет директорию на пустоту
public
isEmpty( $path) : bool
Parameters
Return values
bool —move()
Moves an uploaded file to a new location. If the destination file already exists, it will be overwritten.
public
move(string $dest, string $tempName) : static
Parameters
- $dest : string
- $tempName : string
Return values
static —save()
Метод сохраняет файл и регистрирует его в таблице файлов (files).
public
save([array<string|int, mixed> $arFile = array() ]) : $this
Parameters
- $arFile : array<string|int, mixed> = array()
Tags
Return values
$this —setAddDt()
Задаёт дату добавления, на текущий момент
public
setAddDt() : mixed
Return values
mixed —setContentType()
Задаёт тип файла
public
setContentType(string $content_type) : $this|false
Parameters
- $content_type : string
Return values
$this|false —setFileName()
Задаёт имя файлу
public
setFileName(string $file_name) : $this|false
Parameters
- $file_name : string
Return values
$this|false —setOriginalName()
Задаёт оригинальное имя
public
setOriginalName(string $original_name) : $this|false
Parameters
- $original_name : string
Return values
$this|false —setSize()
Задаёт размер файла
public
setSize(int $size) : $this|false
Parameters
- $size : int
Return values
$this|false —setSubDir()
Задаёт расположение
public
setSubDir(string $sub_dir) : $this
Parameters
- $sub_dir : string
Return values
$this —setUuid()
Задаёт uuid файла
public
setUuid() : $this
Tags
Return values
$this —absoluteResizeDir()
protected
absoluteResizeDir() : string
Return values
string —absoluteUploadDir()
protected
absoluteUploadDir() : string
Return values
string —add()
protected
add( $arFile) : $this|bool
Parameters
Tags
Return values
$this|bool —relativeResizeDir()
protected
relativeResizeDir() : string
Return values
string —relativeUploadDir()
protected
relativeUploadDir() : string
Return values
string —replace()
protected
replace( $arFile) : $this|bool
Parameters
Tags
Return values
$this|bool —update()
protected
update() : $this|false
Tags
Return values
$this|false —validate()
protected
validate() : bool
Return values
bool —__buildFileArray()
Строит массив атрибутов файла
private
__buildFileArray() : array<string|int, mixed>
Return values
array<string|int, mixed> —__changeDir()
*
private
__changeDir() : mixed
Tags
Return values
mixed —__checkMaxCountFilesDir()
Проверяет заполнена ли директори
private
__checkMaxCountFilesDir(string $file) : bool
Parameters
- $file : string
-
Полное имя файла
Return values
bool —__deleteOld()
private
__deleteOld( $file_id_old) : bool
Parameters
Tags
Return values
bool —__findDirToSave()
Выполняет поиск подходящей директории для сохранения файла.
private
__findDirToSave( $path) : mixed|string
Parameters
Return values
mixed|string —__genOnlyDirName()
Создает уникальное имя директории
private
__genOnlyDirName([string $path = '' ]) : string
Parameters
- $path : string = ''
Return values
string —__genOnlyFileName()
Создает уникальное имя файла в указанной директории
private
__genOnlyFileName([string $path = '' ][, string $fname = '' ]) : bool|string
Parameters
- $path : string = ''
-
- полный путь до директории
- $fname : string = ''
-
- имя файла
Return values
bool|string —__prepareDirToSave()
private
__prepareDirToSave() : false|mixed|string
Tags
Return values
false|mixed|string —__prepareSysDir()
private
__prepareSysDir() : bool
Tags
Return values
bool —__rename()
переименовывает файл
private
__rename() : void
Tags
Return values
void —callManager()
Возвращает экземпляр класса FileManager
private
callManager() : FileManager
Return values
FileManager —getPropsToArray()
Преобразует свойства файла в массив
private
getPropsToArray() : array<string|int, mixed>
Return values
array<string|int, mixed> —setProps()
Сохраняет свойство файла в объект
private
setProps( $file) : mixed