Files
api/services/nginx/app/modules/attachments/helpers/attachment_content.php
T
Jeppe Bundgaard 33a26cffc5 Implement attachments module with CRUD operations and integration points
- Added `attachments` module for creating, reading, updating, and deleting attachments.
- Introduced new classes such as `attachments`, `attachment_store`, `attachment_content`, and `attachment_relation` to handle attachment operations and their relationships.
- Integrated `attachments` features into `db_object_t` for seamless object-attachment interactions.
- Added `attachments_i` interface for standardized attachments module operations.
- Created `attachmentsRoute` for defining endpoints related to attachments.
- Enabled module configuration through `attachments_enabled_c` for attachment management control.
2025-09-22 10:28:22 +02:00

51 lines
1.5 KiB
PHP

<?php
namespace attachments\helpers;
class attachment_content
{
public ?string $image; // Used to store the attachment object name, in the attachment store.
public ?string $document; // Used to store the attachment object name, in the attachment store.
public ?attachment_relation $relation; // Used to store the attachment relation object.
public mixed $other; // Used to store the attachment object. (if any other type)
public function __construct(?object $data = null)
{
$this->image = $data->image ?? null;
$this->document = $data->document ?? null;
$this->relation = isset($data->relation) ? new attachment_relation($data->relation) : null;
$this->other = $data->other ?? null;
}
public function toArray(): array
{
return [
'image' => $this->image,
'document' => $this->document,
'relation' => $this->relation ? $this->relation->toArray() : null,
'other' => $this->other,
];
}
/** Setters */
public function setOther(mixed $string): self
{
$this->other = $string;
return $this;
}
public function setImage(string $string): self
{
$this->image = $string;
return $this;
}
public function setDocument(string $string): self
{
$this->document = $string;
return $this;
}
public function setRelation(attachment_relation $relation): self
{
$this->relation = $relation;
return $this;
}
}