Sapphire Documentation

Sapphire\Collection\Collection::class

class Collection

use CollectionFactory;

use CollectionEntryFactory;

use CollectionQueries;

use CollectionSaver;

use CollectionUtilities;

use CollectionAPI;

use Serialize;


public CollectionInfo $info $info - Contains information about collection

public CollectionSchema $schema - Contains collection schema

public array $contents - Contains collection entries


public function SetInfo(CollectionInfo $info): void - Set collection info

public function SetSchema(CollectionSchema $schema): void - Set collection schema

public function SetContents(array $contents): void - Set collection entries


trait CollectionAPI

public static function Get(string $collection_name): Collection | null - Returns collection if collection with provided name exists or null.


trait CollectionEntryFactory

public function MakeEntry(string $name, stdClass $filled_data, User $user): stdClass - Makes entry where $name is name of entry, $filled_data are attributes of entry, $user is used to fill created_by, updated_by


trait CollectionFactory

public static function File(Sapphire\File\File $file): Collection - Creates collection class instance from collection json file.

public static function Make(string $name): Collection - Creates new collection.

public static function GetByFilename(string $name): Collection | null - Returns static::File for file which name is provided.


class CollectionInfo

public string $uuid - contains collection uuid

public string $id - contains collection text id

public string $display_name - contains collection display name

public string $single_name - contains collection singular name


public function SetUuid(string $uuid): void - set collection uuid

public function SetId(string $id): void - set collection id

public function SetDisplayName(string $display_name): void - set collection display name

public function SetSingleName(string $single_name): void - set collection singular name

public static function Raw(stdClass $json): CollectionInfo - Creates CollectionInfo from raw json object


trait CollectionQueries

public function DeleteEntry(string|null $id = null, string|null $uuid = null): void - Deletes single entry by uuid or id

public function GetEntryAndEntryIndexById(string $id): array - Returns entry and entry index (id in array) by id

public function GetEntryAndEntryIndexByUuid(string $uuid): array - Return entry and entry index (id in array) by uuid

public function EditEntry(string|null $id = null, string|null $uuid = null, $attributes = null): void - Edit entry (with passed is or null) replace all of its attributes.

public function Insert($entry): void - Insert entry (json object) into collection

public function CountRecords(): int - Returns how many records collection has

public function IsEmpty(): bool - Returns if collection is empty

public function Entry(string $name) - Returns collection entry

public function All(): array - Returns all collection entries


trait CollectionSaver

public function Save(): void - Saves the collection


trait CollectionUtilities

public function LastEntryIndex(): int - Returns last entry index