Attachment extends Component

Handles file attachments.

Table of Contents

__construct()  : mixed
Class constructor.
delete_attachment()  : mixed
Deletes attachment.
delete_attachments()  : mixed
Deletes attachments.
generate_filename()  : string
Generates a unique filename.
is_valid_file()  : bool
Checks if the file is valid.
set_parent_id()  : array<string|int, mixed>
Sets the attachment parent ID.
boot()  : mixed
Bootstraps component properties.
set_callbacks()  : mixed
Sets the action and filter callbacks.
set_property()  : mixed
Sets a property value.

Methods

__construct()

Class constructor.

public __construct([array<string|int, mixed> $args = [] ]) : mixed
Parameters
$args : array<string|int, mixed> = []

Component arguments.

Return values
mixed

delete_attachment()

Deletes attachment.

public delete_attachment(int $attachment_id, object $attachment) : mixed
Parameters
$attachment_id : int

Attachment ID.

$attachment : object

Attachment object.

Return values
mixed

delete_attachments()

Deletes attachments.

public delete_attachments(int $parent_id, string $parent_alias) : mixed
Parameters
$parent_id : int

Parent ID.

$parent_alias : string

Parent alias.

Return values
mixed

generate_filename()

Generates a unique filename.

public generate_filename(string $filename, string $ext, string $dir) : string
Parameters
$filename : string

Filename.

$ext : string

Extension.

$dir : string

Directory.

Return values
string

is_valid_file()

Checks if the file is valid.

public is_valid_file(string $path, string $name, array<string|int, mixed> $exts) : bool
Parameters
$path : string

File path.

$name : string

File name.

$exts : array<string|int, mixed>

Allowed extensions.

Return values
bool

set_parent_id()

Sets the attachment parent ID.

public set_parent_id(array<string|int, mixed> $attachment, array<string|int, mixed> $args) : array<string|int, mixed>
Parameters
$attachment : array<string|int, mixed>

Attachment arguments.

$args : array<string|int, mixed>

Query arguments.

Return values
array<string|int, mixed>

set_callbacks()

Sets the action and filter callbacks.

protected final set_callbacks(array<string|int, mixed> $callbacks) : mixed
Parameters
$callbacks : array<string|int, mixed>

Callback arguments.

Return values
mixed

set_property()

Sets a property value.

protected final set_property(string $name, mixed $value[, string $prefix = '' ]) : mixed
Parameters
$name : string

Property name.

$value : mixed

Property value.

$prefix : string = ''

Method prefix.

Return values
mixed