Documentation

BaseFile
in package
implements IFile

Class BaseFile

Tags
subpackage

Modules\Files\Models

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

$content_type

public mixed $content_type

$new_file_name

public mixed $new_file_name

$old_file_name

public mixed $old_file_name

$original_name

public mixed $original_name

$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_tags_files

private mixed $table_tags_files = 'tags_files'

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
$path :
$mode : int = 755
$recursive : bool = true
Tags
throws
FileCreateDirFail
Return values
bool

delete()

Удаляет файл

public delete() : bool
Tags
throws
FileDelFail
Return values
bool

get()

public get(int $file_id) : $this|bool
Parameters
$file_id : int
Tags
throws
FileNotFound
Return values
$this|bool

getChildDir()

Возвращает массив дочерних директорий

public getChildDir( $path) : array<string|int, mixed>
Parameters
$path :
  • полный путь до директории
Return values
array<string|int, mixed>

getPath()

Возвращает путь до файла

public getPath() : bool|string
Return values
bool|string

isEmpty()

Проверяет директорию на пустоту

public isEmpty( $path) : bool
Parameters
$path :
  • '/upload/system/awd'
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
throws
FileCreateDirFail
throws
FileDelFail
throws
FileInsertFail
throws
FileNotFound
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
throws
Exception
Return values
$this

absoluteResizeDir()

protected absoluteResizeDir() : string
Return values
string

absoluteUploadDir()

protected absoluteUploadDir() : string
Return values
string

relativeResizeDir()

protected relativeResizeDir() : string
Return values
string

relativeUploadDir()

protected relativeUploadDir() : string
Return values
string

validate()

protected validate() : bool
Return values
bool

__buildFileArray()

Строит массив атрибутов файла

private __buildFileArray() : array<string|int, mixed>
Return values
array<string|int, mixed>

__checkMaxCountFilesDir()

Проверяет заполнена ли директори

private __checkMaxCountFilesDir(string $file) : bool
Parameters
$file : string

Полное имя файла

Return values
bool

__findDirToSave()

Выполняет поиск подходящей директории для сохранения файла.

private __findDirToSave( $path) : mixed|string
Parameters
$path :
  • путь до директории
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
throws
FileCreateDirFail
Return values
false|mixed|string

__rename()

переименовывает файл

private __rename() : void
Tags
throws
FileUpdateFail
Return values
void

getPropsToArray()

Преобразует свойства файла в массив

private getPropsToArray() : array<string|int, mixed>
Return values
array<string|int, mixed>

setProps()

Сохраняет свойство файла в объект

private setProps( $file) : mixed
Parameters
$file :
Return values
mixed

Search results