abstract class SMBBase1 extends FWrapper

Traits

A storage that has a base path

Constants

IDLength

The length of the ID used to identify the object

Properties

protected $database

The object's primary reference to the database

from  BaseObject
protected Scalar> $scalars from  BaseObject
protected ObjectRef> $objects from  BaseObject
protected ObjectRefs> $objectrefs from  BaseObject
private $modified

whether or not this object has been modified

from  BaseObject
private $deleted

whether or not this object has been deleted

from  BaseObject
private $dbDeleted

whether or not this object has been deleted by DB

from  BaseObject
private $deleteLater from  BaseObject
private $created

True if this object has been created and not yet saved to DB

from  BaseObject
static private $instances

array of all instantiated storages

from  Storage
protected $createdItems

array of paths that were newly created

from  Storage
protected $onRollback

array of functions to run for rollback

from  Storage
private $contexts

array<path, FileContext> map for all file handles

from  FWrapper

Methods

static array
GetFieldTemplate()

No description

from  BasePath
static string
GetDBClass()

Returns the name of the class that should be used in the database for the table name (cast down at save)

static string
GetObjClass(array $row)

No description

static int
CountByQuery(ObjectDatabase $database, QueryBuilder $query)

Counts objects in the DB matching the given query

static array
LoadByQuery(ObjectDatabase $database, QueryBuilder $query)

Loads an array of objects from the DB matching the given query

static int
DeleteByQuery(ObjectDatabase $database, QueryBuilder $query)

Deletes objects from the DB matching the given query

static BaseObject|null
TryLoadUniqueByQuery(ObjectDatabase $database, QueryBuilder $query)

Loads a unique object matching the given query

static BaseObject
NotNull(BaseObject|null $obj)

Asserts that the given object is not null

static BaseObject|null
TryLoadByID(ObjectDatabase $database, string $id)

Loads a unique object by its ID

static void
DeleteByID(ObjectDatabase $database, string $id)

Deletes a unique object by its ID

static array
LoadAll(ObjectDatabase $database, int|null $limit = null, int|null $offset = null)

Loads all objects of this type from the database

static int
DeleteAll(ObjectDatabase $database)

Deletes all objects of this type from the database

static array
LoadByObjectID(ObjectDatabase $database, string $field, string $id, string|null $class = null)

Loads objects from the database with the given object ID as the value of the given field

static int
DeleteByObjectID(ObjectDatabase $database, string $field, string $id, string|null $class = null)

Deletes objects from the database with the given object ID as the value of the given field

static BaseObject|null
TryLoadUniqueByKey(ObjectDatabase $database, string $field, string $key)

Loads a unique object matching the given field

static bool
TryDeleteByUniqueKey(ObjectDatabase $database, string $field, string $key)

Deletes a unique object matching the given field

static array
LoadByObject(ObjectDatabase $database, string $field, BaseObject $object, bool $isPoly = false)

Loads objects from the database with the given object referenced by the given field

static int
DeleteByObject(ObjectDatabase $database, string $field, BaseObject $object, bool $isPoly = false)

Deletes objects from the database with the given object referenced by the given field

static BaseObject|null
TryLoadUniqueByObject(ObjectDatabase $database, string $field, BaseObject $object, bool $isPoly = false)

Loads a unique object from the database with the given object referenced by the given field

static bool
TryDeleteByUniqueObject(ObjectDatabase $database, string $field, BaseObject $object, bool $isPoly = false)

Deletes a unique object from the database with the given object referenced by the given field

string
ID()

Returns the unique ID of the object

string
__toString()

Returns the string "id:class" where id is the object ID and class is its short class name

static string|null
toString(BaseObject|null $obj)

Returns the given object's as a string if not null, else null

mixed
GetScalar(string $field, bool $allowTemp = true)

Gets a scalar field

TryGetScalar(string $field, bool $allowTemp = true)

Same as GetScalar() but returns null instead of throwing exceptions

int
GetScalarDelta(string $field)

Returns the delta of the given scalar (non-zero if modified)

GetObject(string $field)

Gets a single object reference

BaseObject|null
TryGetObject(string $field)

Same as GetObject() but returns null instead of throwing exceptions

bool
HasObject(string $field)

Checks if the object reference is not-null without actually loading it (faster)

string
GetObjectID(string $field)

Gets the ID of a referenced object without actually loading it (faster)

string|null
TryGetObjectID(string $field)

Same as GetObjectID() but returns null instead of throwing exceptions

string
GetObjectType(string $field)

Gets the class name of a referenced object without actually loading it (faster)

string|null
TryGetObjectType(string $field)

Gets the class name of a referenced object without actually loading it (faster)

DeleteObject(string $field)

Deletes the object referenced in the field

array
GetObjectRefs(string $field, int|null $limit = null, int|null $offset = null)

Gets an array of objects that reference this object

int
CountObjectRefs(string $field)

Gets the counter of objects referencing this object

GetJoinObject(string $field, BaseObject $obj)

Loads the object that joins together two classes using a FieldTypes\ObjectJoin

StandardObject|null
TryGetJoinObject(string $field, BaseObject $obj)

Same as GetJoinObject() but returns null instead of throwing exceptions

DeleteObjects(string $field)

Deletes all objects that reference this object

SetScalar(string $field, mixed $value, bool $temp = false)

Sets a scalar field to the given value

DeltaCounter(string $name, int $delta = 1, bool $ignoreLimit = false)

Increment a counter by the given value

bool
BoolSetObject(string $field, BaseObject|null $object, bool $notification = false)

Sets a field to reference the given object

SetObject(string $field, BaseObject|null $object, bool $notification = false)

Same as BoolSetObject() but returns $this

bool
AddObjectRef(string $field, BaseObject $object, bool $notification = false)

Adds an object reference, checking for a limit on the number of references

bool
RemoveObjectRef(string $field, BaseObject $object, bool $notification = false)

Removes the given object from a collection of referenced objects

__construct(ObjectDatabase $database, array $data)

Constructs the object by initializing its field template with values from the database

AddField(string $key, Scalar $field)

Adds the given field object to the correct internal array

void
SubConstruct()

Function to allow subclasses to do something after being constructed without overriding the constructor

from  Storage
Save(bool $onlyMandatory = false)

Collects fields that have changed and saves them to the database

bool
isDeleted()

whether or not this object has been, or should be considered, deleted

void
NotifyDBDeleted()

Deletes this object without sending to the DB

void
Delete()

Deletes this object from the DB

void
DeleteLater()

Schedules the object to be deleted when Save() is called

bool
isCreated()

True if this object has been created and not yet saved to DB (should not be overriden)

static BaseObject
BaseCreate(ObjectDatabase $database)

Create the object by setting its created date

float
GetDate(string $name)

Returns the timestamp value stored in the given date field

float|null
TryGetDate(string $name)

Returns the timestamp value stored in the given date field

SetDate(string $name, float|null $value = null)

Sets the value of the given date field to the given value

float
GetDateCreated()

Returns the timestamp when this object was created

int
GetFeatureInt(string $name, bool $allowTemp = true)

Gets the value of the given feature field as an int (used for config)

int|null
TryGetFeatureInt(string $name, bool $allowTemp = true)

Gets the value of the given feature field as an int (used for config)

bool
GetFeatureBool(string $name, bool $allowTemp = true)

Gets the value of the given feature field as a bool (used for config)

bool|null
TryGetFeatureBool(string $name, bool $allowTemp = true)

Gets the value of the given feature field as a bool (used for config)

SetFeatureInt(string $name, int|null $value, bool $temp = false)

Sets the value of the given feature field to the given (?int) value

SetFeatureBool(string $name, bool|null $value, bool $temp = false)

Sets the value of the given feature field to the given (?bool) value

bool
isFeatureModified(string $name)

Returns true if the given feature has been modified

int
GetCounter(string $name)

Gets the value of the given counter field

int
GetCounterLimit(string $name)

Gets the value of the given counter limit field

int|null
TryGetCounterLimit(string $name)

Gets the value of the given counter limit field

SetCounterLimit(string $name, int|null $value, bool $temp = false)

Sets the value of the given counter limit field

bool
CheckCounter(string $name, int $delta = 0, bool $except = true)

Checks whether the given counter plus a delta would exceed the limit

array
GetAllScalars(string|null $prefix)

Gets an array of the values of all fields matching a prefix

Account|null
GetAccount()

Returns the account that owns this storage (or null)

from  Storage
GetFilesystem()

Returns the FSManager that manages this storage

from  Storage
static array
LoadByAccount(ObjectDatabase $database, Account $account)

Loads all storages for the given account (join with FSManager)

from  Storage
array
GetClientObject(bool $activate = false)

No description

from  BasePath
static string
GetCreateUsage()

No description

from  BasePath
static Storage
Create(ObjectDatabase $database, Input $input, FSManager $filesystem)

No description

from  BasePath
static string
GetEditUsage()

No description

from  BasePath
Edit(Input $input)

No description

from  BasePath
Test()

Asserts that the underlying storage can be connected and read from/written to

from  Storage
bool
supportsFolders()

By default, most storages support using folders

from  Storage
bool
usesBandwidth()

By default, most storages use network bandwidth

from  Storage
bool
canGetFreeSpace()

Returns whether or not the storage supports getting free space

from  Storage
int
GetFreeSpace()

Returns the available space in bytes on the storage

from  Storage
Activate()

Activates the storage by making any required connections

from  Storage
void
assertReadable()

Asserts that the filesystem root can be read

from  FWrapper
void
assertWriteable()

Asserts that the filesystem root can be written to

from  FWrapper
void
TestWriteable()

Manually tests if the root is writeable by uploading a test file

from  Storage
AssertNotReadOnly()

Asserts that the storage is not read only

from  Storage
bool
isDryRun()

Returns true if the server is set to dry run mode

from  Storage
disallowBatch()

Disallows running a batch transaction

from  Storage
ItemStat(string $path)

Returns an ItemStat object on the given path

from  FWrapper
int
getSize(string $path)

Returns the size of the file with the given path

from  Storage
bool
isFolder(string $path)

Returns true if the given path is a folder

from  FWrapper
bool
isFile(string $path)

Returns true if the given path is a file

from  FWrapper
array
ReadFolder(string $path)

Lists the contents of a folder

from  Storage
array
SubReadFolder(string $path)

The storage-specific ReadFolder

from  FWrapper
CreateFolder(string $path)

Asserts that the folder with the given path exists

from  Storage
SubCreateFolder(string $path)

The storage-specific CreateFolder

from  FWrapper
CreateFile(string $path)

Creates a new empty file at the given path

from  Storage
SubCreateFile(string $path)

The storage-specific CreateFile

from  FWrapper
ImportFile(string $src, string $dest, bool $istemp)

Imports an existing file into the storage

from  Storage
SubImportFile(string $src, string $dest, bool $istemp)

The storage-specific ImportFile

from  FWrapper
string
ReadBytes(string $path, int $start, int $length)

Reads data from a file

from  Storage
string
SubReadBytes(string $path, int $start, int $length)

The storage-specific ReadBytes

from  FWrapper
WriteBytes(string $path, int $start, string $data)

Writes data to a file

from  Storage
SubWriteBytes(string $path, int $start, string $data)

The storage-specific WriteBytes

from  FWrapper
Truncate(string $path, int $length)

Truncates the file (changes size)

from  Storage
SubTruncate(string $path, int $length)

The storage-specific Truncate

from  FWrapper
DeleteFile(string $path)

Deletes the file with the given path - NO ROLLBACK

from  Storage
SubDeleteFile(string $path)

The storage-specific DeleteFile

from  FWrapper
DeleteFolder(string $path)

Deletes the empty folder with the given path - NO ROLLBACK

from  Storage
SubDeleteFolder(string $path)

The storage-specific DeleteFolder

from  FWrapper
RenameFile(string $old, string $new)

Renames a file from $old to $new - path shall not change

from  Storage
SubRenameFile(string $old, string $new)

The storage-specific RenameFile

from  FWrapper
RenameFolder(string $old, string $new)

Renames a folder from $old to $new - path shall not change

from  Storage
SubRenameFolder(string $old, string $new)

The storage-specific RenameFolder

from  FWrapper
MoveFile(string $old, string $new)

Moves a file from $old to $new - name shall not change

from  Storage
SubMoveFile(string $old, string $new)

The storage-specific MoveFile

from  FWrapper
MoveFolder(string $old, string $new)

Moves a folder from $old to $new - name shall not change

from  Storage
SubMoveFolder(string $old, string $new)

The storage-specific MoveFolder

from  FWrapper
CopyFile(string $old, string $new)

Copies a file from $old to $new (path and name can change)

from  Storage
SubCopyFile(string $old, string $new)

The storage-specific CopyFile

from  FWrapper
CopyFolder(string $old, string $new)

Copies a folder from $old to $new (path and name can change)

from  Storage
SubCopyFolder(string $old, string $new)

The storage-specific CopyFolder

from  Storage
bool
canCopyFolders()

By default, most storages cannot copy whole folders

from  Storage
renameRollbacks(string $old, string $new)

Moves all pending rollback actions from $old to $new for delete tracking

from  Storage
deleteRollbacks(string $path)

Deletes all pending rollback actions for the given path

from  Storage
commit()

No description

from  Storage
rollback()

No description

from  Storage
static 
commitAll()

Commits all instantiated filesystems

from  Storage
static 
rollbackAll()

Rolls back all instantiated filesystems

from  Storage
string
GetFullURL(string $path = "")

Returns the full fwrapper URL for the given path

from  FWrapper
static bool
supportsReadWrite()

Returns true if we can read from a stream opened as write

from  FWrapper
static bool
supportsSeekReuse()

Returns true if an already-open stream can be seeked randomly

from  FWrapper
OpenReadHandle(string $path)

Returns a read handle for the given path

from  FWrapper
OpenWriteHandle(string $path)

Returns a write handle for the given path

from  FWrapper
OpenContext(string $path, int $offset, bool $isWrite)

Returns a new handle for the given path

from  FWrapper
GetContext(string $path, int $offset, bool $isWrite)

Returns a context for the given file

from  FWrapper
void
ClosePath(string $path)

Closes any open handles for the given file path

from  FWrapper
string
GetPath(string $path = "")

Returns the full storage level path for the given root-relative path

from  BasePath
SetPath(string $path)

Sets the path of the storage's root

from  BasePath

Details

in BasePath at line 119
static array GetFieldTemplate()

No description

Return Value

array

in BaseObject at line 52
static string GetDBClass()

Returns the name of the class that should be used in the database for the table name (cast down at save)

Defaults to the actual class used. Can be overriden e.g. if multiple classes need to use the same table.

Return Value

string

in BaseObject at line 60
static string GetObjClass(array $row)

No description

Parameters

array $row

Return Value

string

in BaseObject at line 68
static int CountByQuery(ObjectDatabase $database, QueryBuilder $query)

Counts objects in the DB matching the given query

Parameters

ObjectDatabase $database

Reference to the database

QueryBuilder $query

The query to use for matching objects

Return Value

int

count of matched objects

in BaseObject at line 79
static array LoadByQuery(ObjectDatabase $database, QueryBuilder $query)

Loads an array of objects from the DB matching the given query

Parameters

ObjectDatabase $database

Reference to the database

QueryBuilder $query

The query to use for matching objects

Return Value

array

array of objects indexed by their IDs

in BaseObject at line 92
static int DeleteByQuery(ObjectDatabase $database, QueryBuilder $query)

Deletes objects from the DB matching the given query

The objects are loaded when they are deleted and their Delete()s are run

Parameters

ObjectDatabase $database

Reference to the database

QueryBuilder $query

The query to use for matching objects

Return Value

int

number of objects deleted

in BaseObject at line 103
static BaseObject|null TryLoadUniqueByQuery(ObjectDatabase $database, QueryBuilder $query)

Loads a unique object matching the given query

Parameters

ObjectDatabase $database

Reference to the database

QueryBuilder $query

the query to uniquely identify the object

Return Value

BaseObject|null

in BaseObject at line 116
static BaseObject NotNull(BaseObject|null $obj)

Asserts that the given object is not null

Parameters

BaseObject|null $obj

the object to check for null

Return Value

BaseObject

object if not null

Exceptions

ObjectNotFoundException

if the object is null

in BaseObject at line 127
static BaseObject|null TryLoadByID(ObjectDatabase $database, string $id)

Loads a unique object by its ID

Parameters

ObjectDatabase $database

Reference to the database

string $id

the ID of the object

Return Value

BaseObject|null

object or null if not found

in BaseObject at line 137
static void DeleteByID(ObjectDatabase $database, string $id)

Deletes a unique object by its ID

Parameters

ObjectDatabase $database

Reference to the database

string $id

the ID of the object

Return Value

void

in BaseObject at line 150
static array LoadAll(ObjectDatabase $database, int|null $limit = null, int|null $offset = null)

Loads all objects of this type from the database

Parameters

ObjectDatabase $database

Reference to the database

int|null $limit

the maximum number of objects to load

int|null $offset

the number of objects to skip loading

Return Value

array

array of objects indexed by their IDs

in BaseObject at line 160
static int DeleteAll(ObjectDatabase $database)

Deletes all objects of this type from the database

Parameters

ObjectDatabase $database

Reference to the database

Return Value

int

number of deleted objects

in BaseObject at line 176
static array LoadByObjectID(ObjectDatabase $database, string $field, string $id, string|null $class = null)

Loads objects from the database with the given object ID as the value of the given field

Can be used as an alternative to LoadByObject() to avoid actually loading the object

Parameters

ObjectDatabase $database

Reference to the database

string $field

The name of the field to check

string $id

The ID of the object referenced

string|null $class

optionally, the class to match if this column is polymorphic

Return Value

array

array of objects indexed by their IDs

in BaseObject at line 193
static int DeleteByObjectID(ObjectDatabase $database, string $field, string $id, string|null $class = null)

Deletes objects from the database with the given object ID as the value of the given field

Can be used as an alternative to DeleteByObject() to avoid actually loading the object

Parameters

ObjectDatabase $database

Reference to the database

string $field

The name of the field to check

string $id

The ID of the object referenced

string|null $class

optionally, the class to match if this column is polymorphic

Return Value

int

number of rows deleted

in BaseObject at line 206
static protected BaseObject|null TryLoadUniqueByKey(ObjectDatabase $database, string $field, string $key)

Loads a unique object matching the given field

Parameters

ObjectDatabase $database

Reference to the database

string $field

the name of the field to check

string $key

the value of the field that uniquely identifies the object

Return Value

BaseObject|null

in BaseObject at line 218
static protected bool TryDeleteByUniqueKey(ObjectDatabase $database, string $field, string $key)

Deletes a unique object matching the given field

Parameters

ObjectDatabase $database

Reference to the database

string $field

the name of the field to check

string $key

the value of the field that uniquely identifies the object

Return Value

bool

true if an object was deleted

in BaseObject at line 233
static array LoadByObject(ObjectDatabase $database, string $field, BaseObject $object, bool $isPoly = false)

Loads objects from the database with the given object referenced by the given field

Parameters

ObjectDatabase $database

Reference to the database

string $field

The name of the field to check

BaseObject $object

the object referenced by the field

bool $isPoly

whether or not this field is polymorphic

Return Value

array

array of objects indexed by their IDs

in BaseObject at line 247
static int DeleteByObject(ObjectDatabase $database, string $field, BaseObject $object, bool $isPoly = false)

Deletes objects from the database with the given object referenced by the given field

Parameters

ObjectDatabase $database

Reference to the database

string $field

The name of the field to check

BaseObject $object

the object referenced by the field

bool $isPoly

whether or not this field is polymorphic

Return Value

int

number of deleted objects

in BaseObject at line 261
static BaseObject|null TryLoadUniqueByObject(ObjectDatabase $database, string $field, BaseObject $object, bool $isPoly = false)

Loads a unique object from the database with the given object referenced by the given field

Parameters

ObjectDatabase $database

Reference to the database

string $field

The name of the field to check

BaseObject $object

the object referenced by the field

bool $isPoly

whether or not this field is polymorphic

Return Value

BaseObject|null

in BaseObject at line 275
static bool TryDeleteByUniqueObject(ObjectDatabase $database, string $field, BaseObject $object, bool $isPoly = false)

Deletes a unique object from the database with the given object referenced by the given field

Parameters

ObjectDatabase $database

Reference to the database

string $field

The name of the field to check

BaseObject $object

the object referenced by the field

bool $isPoly

whether or not this field is polymorphic

Return Value

bool

true if an object was deleted

in BaseObject at line 284
string ID()

Returns the unique ID of the object

Return Value

string

in BaseObject at line 287
string __toString()

Returns the string "id:class" where id is the object ID and class is its short class name

Return Value

string

in BaseObject at line 290
static string|null toString(BaseObject|null $obj)

Returns the given object's as a string if not null, else null

Parameters

BaseObject|null $obj

Return Value

string|null

in BaseObject at line 309
protected mixed GetScalar(string $field, bool $allowTemp = true)

Gets a scalar field

Parameters

string $field

the field name of the scalar

bool $allowTemp

whether to allow returning a value that was set as temporary

Return Value

mixed

any non-null scalar value

Exceptions

KeyNotFoundException

if the field name is invalid

NullValueException

if the field value is null

in BaseObject at line 322
protected TryGetScalar(string $field, bool $allowTemp = true)

Same as GetScalar() but returns null instead of throwing exceptions

Parameters

string $field
bool $allowTemp

See also

BaseObject::GetScalar

in BaseObject at line 336
protected int GetScalarDelta(string $field)

Returns the delta of the given scalar (non-zero if modified)

Parameters

string $field

the field name of the scalar

Return Value

int

of times modified for scalars, delta for counters

Exceptions

KeyNotFoundException

if the field name is invalid

in BaseObject at line 351
protected BaseObject GetObject(string $field)

Gets a single object reference

Parameters

string $field

the field name holding the reference

Return Value

BaseObject

any object value

Exceptions

KeyNotFoundException

if the field name is invalid

NullValueException

if the field value is null

in BaseObject at line 365
protected BaseObject|null TryGetObject(string $field)

Same as GetObject() but returns null instead of throwing exceptions

Parameters

string $field

Return Value

BaseObject|null

See also

BaseObject::GetObject

in BaseObject at line 379
protected bool HasObject(string $field)

Checks if the object reference is not-null without actually loading it (faster)

Parameters

string $field

the field name holding the reference

Return Value

bool

true if the object reference is not null

Exceptions

KeyNotFoundException

if the field name is invalid

in BaseObject at line 394
protected string GetObjectID(string $field)

Gets the ID of a referenced object without actually loading it (faster)

Parameters

string $field

the field name holding the reference

Return Value

string

the ID of the referenced object

Exceptions

KeyNotFoundException

if the field name is invalid

NullValueException

if the field value is null

in BaseObject at line 408
protected string|null TryGetObjectID(string $field)

Same as GetObjectID() but returns null instead of throwing exceptions

Parameters

string $field

Return Value

string|null

See also

BaseObject::GetObjectID

in BaseObject at line 422
protected string GetObjectType(string $field)

Gets the class name of a referenced object without actually loading it (faster)

Parameters

string $field

the field name holding the reference

Return Value

string

the class name of the referenced object

Exceptions

KeyNotFoundException

if the field name is invalid

in BaseObject at line 438
protected string|null TryGetObjectType(string $field)

Gets the class name of a referenced object without actually loading it (faster)

Parameters

string $field

the field name holding the reference

Return Value

string|null

the class name of the referenced object

Exceptions

KeyNotFoundException

if the field name is invalid

in BaseObject at line 451
protected BaseObject DeleteObject(string $field)

Deletes the object referenced in the field

Parameters

string $field

the field name holding the reference

Return Value

BaseObject

in BaseObject at line 467
protected array GetObjectRefs(string $field, int|null $limit = null, int|null $offset = null)

Gets an array of objects that reference this object

Parameters

string $field

the field name of the collection

int|null $limit

the maximum number of objects to load

int|null $offset

the number of objects to skip loading

Return Value

array

array of objects indexed by their IDs

Exceptions

KeyNotFoundException

if the field name is invalid

in BaseObject at line 481
protected int CountObjectRefs(string $field)

Gets the counter of objects referencing this object

Parameters

string $field

the field name of the collection

Return Value

int

the number of objects

Exceptions

KeyNotFoundException

if the field name is invalid

in BaseObject at line 497
protected StandardObject GetJoinObject(string $field, BaseObject $obj)

Loads the object that joins together two classes using a FieldTypes\ObjectJoin

Parameters

string $field

the field name using the join reference

BaseObject $obj

the object that is joined together with this one

Return Value

StandardObject

the join object that connects us to $obj

Exceptions

KeyNotFoundException

if the field name is invalid

NullValueException

if the given object is not joined to us

in BaseObject at line 514
protected StandardObject|null TryGetJoinObject(string $field, BaseObject $obj)

Same as GetJoinObject() but returns null instead of throwing exceptions

Parameters

string $field
BaseObject $obj

Return Value

StandardObject|null

See also

BaseObject::GetJoinObject

in BaseObject at line 530
protected BaseObject DeleteObjects(string $field)

Deletes all objects that reference this object

Parameters

string $field

the field name of the collection

Return Value

BaseObject

in BaseObject at line 546
protected BaseObject SetScalar(string $field, mixed $value, bool $temp = false)

Sets a scalar field to the given value

Parameters

string $field

the name of the field

mixed $value

the value of the scalar to set

bool $temp

if true, the value is temporary and will not be saved

Return Value

BaseObject

Exceptions

KeyNotFoundException

if the property name is invalid

in StandardObject at line 173
protected BaseObject DeltaCounter(string $name, int $delta = 1, bool $ignoreLimit = false)

Increment a counter by the given value

Parameters

string $name

the name of the counter field to increment

int $delta

the value to increment by

bool $ignoreLimit

if true, ignore the counter's limit

Return Value

BaseObject

Exceptions

CounterOverLimitException

if the counter's limit exists and is exceeded

See also

\Andromeda\Core\Database\BaseObject::DeltaScalar()

in BaseObject at line 598
protected bool BoolSetObject(string $field, BaseObject|null $object, bool $notification = false)

Sets a field to reference the given object

Will also call SetObject or AddObjectRef on the given object as appropriate for two-way references

Parameters

string $field

the name of the reference field

BaseObject|null $object

the object for the field to reference

bool $notification

true if this is a notification from another object that cross-references this one (internal only!)

Return Value

bool

true if this object was modified

Exceptions

KeyNotFoundException

if the property name is invalid

in BaseObject at line 649
protected BaseObject SetObject(string $field, BaseObject|null $object, bool $notification = false)

Same as BoolSetObject() but returns $this

Parameters

string $field
BaseObject|null $object
bool $notification

Return Value

BaseObject

See also

BaseObject::BoolSetObject

in StandardObject at line 185
protected bool AddObjectRef(string $field, BaseObject $object, bool $notification = false)

Adds an object reference, checking for a limit on the number of references

Parameters

string $field

the name of the field of the collection

BaseObject $object

the object to add to the collection

bool $notification

true if this is a notification from another object that cross-references this one (internal only!)

Return Value

bool

true if this object was modified

Exceptions

CounterOverLimitException

if the limit exists and is exceeded

See also

BaseObject::AddObjectRef

in BaseObject at line 696
protected bool RemoveObjectRef(string $field, BaseObject $object, bool $notification = false)

Removes the given object from a collection of referenced objects

Parameters

string $field

the name of the field of the collection

BaseObject $object

the object to add to the collection

bool $notification

true if this is a notification from another object that cross-references this one (internal only!)

Return Value

bool

true if this object was modified

Exceptions

KeyNotFoundException

if the property name is invalid

in BaseObject at line 727
__construct(ObjectDatabase $database, array $data)

Constructs the object by initializing its field template with values from the database

Parameters

ObjectDatabase $database

Reference to the database

array $data

array of columns from the DB in the form of name=>value

in BaseObject at line 750
private AddField(string $key, Scalar $field)

Adds the given field object to the correct internal array

Parameters

string $key
Scalar $field

in Storage at line 651
void SubConstruct()

Function to allow subclasses to do something after being constructed without overriding the constructor

Return Value

void

in BaseObject at line 771
BaseObject Save(bool $onlyMandatory = false)

Collects fields that have changed and saves them to the database

Parameters

bool $onlyMandatory

true if only required fields should be saved

Return Value

BaseObject

Exceptions

RowInsertFailedException

if the insert fails (duplicate?)

in BaseObject at line 814
bool isDeleted()

whether or not this object has been, or should be considered, deleted

This function can be overriden with a custom validity-check, and is used as a filter when loading objects

Return Value

bool

in BaseObject at line 820
void NotifyDBDeleted()

Deletes this object without sending to the DB

Return Value

void

in BaseObject at line 823
void Delete()

Deletes this object from the DB

Return Value

void

in BaseObject at line 849
protected void DeleteLater()

Schedules the object to be deleted when Save() is called

Return Value

void

in BaseObject at line 855
bool isCreated()

True if this object has been created and not yet saved to DB (should not be overriden)

Return Value

bool

in StandardObject at line 51
static protected BaseObject BaseCreate(ObjectDatabase $database)

Create the object by setting its created date

Parameters

ObjectDatabase $database

Return Value

BaseObject

See also

BaseObject::BaseCreate

in StandardObject at line 23
protected float GetDate(string $name)

Returns the timestamp value stored in the given date field

Parameters

string $name

Return Value

float

See also

BaseObject::GetScalar

in StandardObject at line 29
protected float|null TryGetDate(string $name)

Returns the timestamp value stored in the given date field

Parameters

string $name

Return Value

float|null

See also

BaseObject::TryGetScalar

in StandardObject at line 38
protected StandardObject SetDate(string $name, float|null $value = null)

Sets the value of the given date field to the given value

Parameters

string $name

the name of the date field to set

float|null $value

the value of the timestamp, or null to use the current time

Return Value

StandardObject

See also

BaseObject::SetScalar

in StandardObject at line 44
float GetDateCreated()

Returns the timestamp when this object was created

Return Value

float

in StandardObject at line 58
protected int GetFeatureInt(string $name, bool $allowTemp = true)

Gets the value of the given feature field as an int (used for config)

Parameters

string $name
bool $allowTemp

Return Value

int

See also

BaseObject::GetScalar

in StandardObject at line 65
protected int|null TryGetFeatureInt(string $name, bool $allowTemp = true)

Gets the value of the given feature field as an int (used for config)

Parameters

string $name
bool $allowTemp

Return Value

int|null

See also

BaseObject::GetScalar

in StandardObject at line 75
protected bool GetFeatureBool(string $name, bool $allowTemp = true)

Gets the value of the given feature field as a bool (used for config)

Parameters

string $name
bool $allowTemp

Return Value

bool

See also

BaseObject::GetScalar

in StandardObject at line 82
protected bool|null TryGetFeatureBool(string $name, bool $allowTemp = true)

Gets the value of the given feature field as a bool (used for config)

Parameters

string $name
bool $allowTemp

Return Value

bool|null

See also

BaseObject::GetScalar

in StandardObject at line 93
protected StandardObject SetFeatureInt(string $name, int|null $value, bool $temp = false)

Sets the value of the given feature field to the given (?int) value

Parameters

string $name
int|null $value
bool $temp

Return Value

StandardObject

See also

BaseObject::SetScalar

in StandardObject at line 101
protected StandardObject SetFeatureBool(string $name, bool|null $value, bool $temp = false)

Sets the value of the given feature field to the given (?bool) value

Parameters

string $name
bool|null $value
bool $temp

Return Value

StandardObject

See also

BaseObject::SetScalar

in StandardObject at line 105
protected bool isFeatureModified(string $name)

Returns true if the given feature has been modified

Parameters

string $name

Return Value

bool

in StandardObject at line 114
protected int GetCounter(string $name)

Gets the value of the given counter field

Parameters

string $name

Return Value

int

See also

BaseObject::GetScalar

in StandardObject at line 121
protected int GetCounterLimit(string $name)

Gets the value of the given counter limit field

Parameters

string $name

Return Value

int

See also

BaseObject::GetScalar

in StandardObject at line 128
protected int|null TryGetCounterLimit(string $name)

Gets the value of the given counter limit field

Parameters

string $name

Return Value

int|null

See also

BaseObject::TryGetScalar

in StandardObject at line 140
protected StandardObject SetCounterLimit(string $name, int|null $value, bool $temp = false)

Sets the value of the given counter limit field

Parameters

string $name
int|null $value
bool $temp

Return Value

StandardObject

See also

BaseObject::SetScalar

in StandardObject at line 151
protected bool CheckCounter(string $name, int $delta = 0, bool $except = true)

Checks whether the given counter plus a delta would exceed the limit

Parameters

string $name

the name of the counter and counter limit field to check

int $delta

the value to try incrementing the counter by

bool $except

if true, throw an exception instead of returning false

Return Value

bool

if true, the limit exists and is not exceeded

Exceptions

CounterOverLimitException

if $except and retval is false

in StandardObject at line 202
protected array GetAllScalars(string|null $prefix)

Gets an array of the values of all fields matching a prefix

Parameters

string|null $prefix

the prefix to match fields against, or null to get all

Return Value

array

mapping field names (stripped of their prefix) to their values

See also

BaseObject::TryGetScalar

in Storage at line 49
Account|null GetAccount()

Returns the account that owns this storage (or null)

Return Value

Account|null

in Storage at line 52
FSManager GetFilesystem()

Returns the FSManager that manages this storage

Return Value

FSManager

in Storage at line 55
static array LoadByAccount(ObjectDatabase $database, Account $account)

Loads all storages for the given account (join with FSManager)

Parameters

ObjectDatabase $database
Account $account

Return Value

array

in BasePath at line 126
array GetClientObject(bool $activate = false)

No description

Parameters

bool $activate

Return Value

array

in BasePath at line 133
static string GetCreateUsage()

No description

Return Value

string

in BasePath at line 135
static Storage Create(ObjectDatabase $database, Input $input, FSManager $filesystem)

No description

Parameters

ObjectDatabase $database
Input $input
FSManager $filesystem

Return Value

Storage

in BasePath at line 141
static string GetEditUsage()

No description

Return Value

string

in BasePath at line 143
Storage Edit(Input $input)

No description

Parameters

Input $input

Return Value

Storage

in Storage at line 110
Storage Test()

Asserts that the underlying storage can be connected and read from/written to

Return Value

Storage

in Storage at line 124
bool supportsFolders()

By default, most storages support using folders

Return Value

bool

in Storage at line 127
bool usesBandwidth()

By default, most storages use network bandwidth

Return Value

bool

in Storage at line 130
bool canGetFreeSpace()

Returns whether or not the storage supports getting free space

Return Value

bool

in Storage at line 133
int GetFreeSpace()

Returns the available space in bytes on the storage

Return Value

int

in Storage at line 136
abstract Storage Activate()

Activates the storage by making any required connections

Return Value

Storage

in FWrapper at line 54
protected void assertReadable()

Asserts that the filesystem root can be read

Return Value

void

in FWrapper at line 60
protected void assertWriteable()

Asserts that the filesystem root can be written to

Return Value

void

in Storage at line 149
protected void TestWriteable()

Manually tests if the root is writeable by uploading a test file

Can be used to implement assertWriteable() if no function exists

Return Value

void

in Storage at line 163
protected Storage AssertNotReadOnly()

Asserts that the storage is not read only

Return Value

Storage

Exceptions

ReadOnlyException

if the filesystem or server are read only

in Storage at line 175
protected bool isDryRun()

Returns true if the server is set to dry run mode

Return Value

bool

in Storage at line 181
protected Storage disallowBatch()

Disallows running a batch transaction

Return Value

Storage

in FWrapper at line 37
ItemStat ItemStat(string $path)

Returns an ItemStat object on the given path

Parameters

string $path

Return Value

ItemStat

in Storage at line 190
int getSize(string $path)

Returns the size of the file with the given path

Parameters

string $path

Return Value

int

in FWrapper at line 44
bool isFolder(string $path)

Returns true if the given path is a folder

Parameters

string $path

Return Value

bool

in FWrapper at line 49
bool isFile(string $path)

Returns true if the given path is a file

Parameters

string $path

Return Value

bool

in Storage at line 203
array ReadFolder(string $path)

Lists the contents of a folder

Parameters

string $path

folder path

Return Value

array

array of names

in FWrapper at line 66
protected array SubReadFolder(string $path)

The storage-specific ReadFolder

Parameters

string $path

Return Value

array

in Storage at line 215
Storage CreateFolder(string $path)

Asserts that the folder with the given path exists

Parameters

string $path

Return Value

Storage

in FWrapper at line 73
protected Storage SubCreateFolder(string $path)

The storage-specific CreateFolder

Parameters

string $path

Return Value

Storage

in Storage at line 242
Storage CreateFile(string $path)

Creates a new empty file at the given path

If it already exists, overwrites + NO ROLLBACK

Parameters

string $path

Return Value

Storage

in FWrapper at line 80
protected Storage SubCreateFile(string $path)

The storage-specific CreateFile

Parameters

string $path

Return Value

Storage

in Storage at line 279
Storage ImportFile(string $src, string $dest, bool $istemp)

Imports an existing file into the storage

If it already exists, overwrites + NO ROLLBACK

Parameters

string $src

file to import

string $dest

path of new file

bool $istemp

true if we can move the src

Return Value

Storage

in FWrapper at line 87
protected Storage SubImportFile(string $src, string $dest, bool $istemp)

The storage-specific ImportFile

Parameters

string $src
string $dest
bool $istemp

Return Value

Storage

in Storage at line 314
string ReadBytes(string $path, int $start, int $length)

Reads data from a file

Parameters

string $path

file to read

int $start

byte offset to read

int $length

exact number of bytes to read

Return Value

string

file data

in FWrapper at line 168
protected string SubReadBytes(string $path, int $start, int $length)

The storage-specific ReadBytes

Parameters

string $path
int $start
int $length

Return Value

string

in Storage at line 334
Storage WriteBytes(string $path, int $start, string $data)

Writes data to a file

NO ROLLBACK if within existing bounds

Parameters

string $path

file to write

int $start

byte offset to write

string $data

data to write

Return Value

Storage

in FWrapper at line 179
protected Storage SubWriteBytes(string $path, int $start, string $data)

The storage-specific WriteBytes

Parameters

string $path
int $start
string $data

Return Value

Storage

in Storage at line 379
Storage Truncate(string $path, int $length)

Truncates the file (changes size)

NO ROLLBACK if shrinking the file

Parameters

string $path

file to resize

int $length

new length of file

Return Value

Storage

in FWrapper at line 96
protected Storage SubTruncate(string $path, int $length)

The storage-specific Truncate

Parameters

string $path
int $length

Return Value

Storage

in Storage at line 405
Storage DeleteFile(string $path)

Deletes the file with the given path - NO ROLLBACK

Parameters

string $path

Return Value

Storage

in FWrapper at line 111
protected Storage SubDeleteFile(string $path)

The storage-specific DeleteFile

Parameters

string $path

Return Value

Storage

in Storage at line 423
Storage DeleteFolder(string $path)

Deletes the empty folder with the given path - NO ROLLBACK

Parameters

string $path

Return Value

Storage

in FWrapper at line 120
protected Storage SubDeleteFolder(string $path)

The storage-specific DeleteFolder

Parameters

string $path

Return Value

Storage

in Storage at line 445
Storage RenameFile(string $old, string $new)

Renames a file from $old to $new - path shall not change

NO ROLLBACK if overwriting an existing file

Parameters

string $old
string $new

Return Value

Storage

in FWrapper at line 127
protected Storage SubRenameFile(string $old, string $new)

The storage-specific RenameFile

Parameters

string $old
string $new

Return Value

Storage

in Storage at line 479
Storage RenameFolder(string $old, string $new)

Renames a folder from $old to $new - path shall not change

The destination folder must not already exist

Parameters

string $old
string $new

Return Value

Storage

in FWrapper at line 136
protected Storage SubRenameFolder(string $old, string $new)

The storage-specific RenameFolder

Parameters

string $old
string $new

Return Value

Storage

in Storage at line 513
Storage MoveFile(string $old, string $new)

Moves a file from $old to $new - name shall not change

NO ROLLBACK if overwriting an existing file

Parameters

string $old
string $new

Return Value

Storage

in FWrapper at line 143
protected Storage SubMoveFile(string $old, string $new)

The storage-specific MoveFile

Parameters

string $old
string $new

Return Value

Storage

in Storage at line 547
Storage MoveFolder(string $old, string $new)

Moves a folder from $old to $new - name shall not change

The destination folder must not already exist

Parameters

string $old
string $new

Return Value

Storage

in FWrapper at line 152
protected Storage SubMoveFolder(string $old, string $new)

The storage-specific MoveFolder

Parameters

string $old
string $new

Return Value

Storage

in Storage at line 581
Storage CopyFile(string $old, string $new)

Copies a file from $old to $new (path and name can change)

NO ROLLBACK if overwriting an existing file

Parameters

string $old
string $new

Return Value

Storage

in FWrapper at line 159
protected Storage SubCopyFile(string $old, string $new)

The storage-specific CopyFile

Parameters

string $old
string $new

Return Value

Storage

in Storage at line 614
Storage CopyFolder(string $old, string $new)

Copies a folder from $old to $new (path and name can change)

The destination folder must not already exist

Parameters

string $old
string $new

Return Value

Storage

in Storage at line 640
protected Storage SubCopyFolder(string $old, string $new)

The storage-specific CopyFolder

Parameters

string $old
string $new

Return Value

Storage

See also

Storage::CopyFolder

in Storage at line 646
bool canCopyFolders()

By default, most storages cannot copy whole folders

Return Value

bool

in Storage at line 662
protected Storage renameRollbacks(string $old, string $new)

Moves all pending rollback actions from $old to $new for delete tracking

Parameters

string $old

old path of item

string $new

new path of item

Return Value

Storage

in Storage at line 680
protected Storage deleteRollbacks(string $path)

Deletes all pending rollback actions for the given path

Parameters

string $path

Return Value

Storage

in Storage at line 690
commit()

No description

in Storage at line 699
rollback()

No description

in Storage at line 709
static commitAll()

Commits all instantiated filesystems

in Storage at line 713
static rollbackAll()

Rolls back all instantiated filesystems

in FWrapper at line 35
abstract protected string GetFullURL(string $path = "")

Returns the full fwrapper URL for the given path

Parameters

string $path

Return Value

string

in FWrapper at line 194
static protected bool supportsReadWrite()

Returns true if we can read from a stream opened as write

Return Value

bool

in FWrapper at line 197
static protected bool supportsSeekReuse()

Returns true if an already-open stream can be seeked randomly

Return Value

bool

in FWrapper at line 200
protected OpenReadHandle(string $path)

Returns a read handle for the given path

Parameters

string $path

in FWrapper at line 203
protected OpenWriteHandle(string $path)

Returns a write handle for the given path

Parameters

string $path

in FWrapper at line 214
protected FileContext OpenContext(string $path, int $offset, bool $isWrite)

Returns a new handle for the given path

Parameters

string $path

path of file

int $offset

offset to initialize to

bool $isWrite

true if this is a write

Return Value

FileContext

new file context

Exceptions

FileOpenFailedException

if opening fails

FileSeekFailedException

if seeking fails

in FWrapper at line 232
protected FileContext GetContext(string $path, int $offset, bool $isWrite)

Returns a context for the given file

Parameters

string $path

path to file

int $offset

desired byte offset

bool $isWrite

true if write access is needed

Return Value

FileContext

file stream context

in FWrapper at line 264
protected void ClosePath(string $path)

Closes any open handles for the given file path

Parameters

string $path

Return Value

void

in BasePath at line 151
protected string GetPath(string $path = "")

Returns the full storage level path for the given root-relative path

Parameters

string $path

Return Value

string

in BasePath at line 157
private Storage SetPath(string $path)

Sets the path of the storage's root

Parameters

string $path

Return Value

Storage