Nextcloud PHP API (master)

SnowflakeAwareEntity extends Entity
in package

AbstractYes

Entity with snowflake support

Tags
since
33.0.0
Attributes
#[Consumable]
$since: '33.0.0'

Table of Contents

Properties

$id  : int
$_fieldTypes  : array<string|int, mixed>
$snowflake  : Snowflake|null

Methods

__call()  : mixed
Each time a setter is called, push the part after set into an array: for instance setId will save Id in the updated fields array so it can be easily used to create the getter method
columnToProperty()  : string
Transform a database columnname to a property
fromParams()  : static
Simple alternative constructor for building entities from a request
fromRow()  : static
Maps the keys of the row array to the attributes
generateId()  : void
Automatically creates a snowflake ID
getCreatedAt()  : DateTimeImmutable|null
getFieldTypes()  : array<string, Types::*>
getId()  : string
getSnowflake()  : Snowflake|null
getUpdatedFields()  : array<string, true>
propertyToColumn()  : string
Transform a property to a database column name
resetUpdatedFields()  : void
Marks the entity as clean needed for setting the id after the insertion
setId()  : void
slugify()  : string
Slugify the value of a given attribute Warning: This doesn't result in a unique value
addType()  : void
Adds type information for a field so that it's automatically cast to that value once its being returned from the database
getter()  : mixed
Generic getter for properties
isGetterForBoolProperty()  : bool
markFieldUpdated()  : void
Mark am attribute as updated
setter()  : void
Generic setter for properties

Properties

$_fieldTypes

protected array<string|int, mixed> $_fieldTypes = ['id' => \OCP\DB\Types::STRING]
Tags
psalm-param

$_fieldTypes array<string, Types::*>

Methods

__call()

Each time a setter is called, push the part after set into an array: for instance setId will save Id in the updated fields array so it can be easily used to create the getter method

public __call(string $methodName, array<string|int, mixed> $args) : mixed
Parameters
$methodName : string
$args : array<string|int, mixed>
Tags
since
7.0.0

columnToProperty()

Transform a database columnname to a property

public columnToProperty(string $columnName) : string
Parameters
$columnName : string

the name of the column

Tags
since
7.0.0
Return values
string

the property name

fromParams()

Simple alternative constructor for building entities from a request

public static fromParams(array<string|int, mixed> $params) : static
Parameters
$params : array<string|int, mixed>

the array which was obtained via $this->params('key') in the controller

Tags
since
7.0.0
Return values
static

fromRow()

Maps the keys of the row array to the attributes

public static fromRow(array<string|int, mixed> $row) : static
Parameters
$row : array<string|int, mixed>

the row to map onto the entity

Tags
since
7.0.0
Return values
static

getCreatedAt()

public getCreatedAt() : DateTimeImmutable|null
Return values
DateTimeImmutable|null

getFieldTypes()

public getFieldTypes() : array<string, Types::*>
Tags
since
7.0.0
Return values
array<string, Types::*>

with attribute and type

getUpdatedFields()

public getUpdatedFields() : array<string, true>
Tags
since
7.0.0
Return values
array<string, true>

array of updated fields for update query

propertyToColumn()

Transform a property to a database column name

public propertyToColumn(string $property) : string
Parameters
$property : string

the name of the property

Tags
since
7.0.0
Return values
string

the column name

resetUpdatedFields()

Marks the entity as clean needed for setting the id after the insertion

public resetUpdatedFields() : void
Tags
since
7.0.0

slugify()

Slugify the value of a given attribute Warning: This doesn't result in a unique value

public slugify(string $attributeName) : string
Parameters
$attributeName : string

the name of the attribute, which value should be slugified

Tags
since
7.0.0
Return values
string

slugified value

addType()

Adds type information for a field so that it's automatically cast to that value once its being returned from the database

protected addType(string $fieldName, Types::* $type) : void
Parameters
$fieldName : string

the name of the attribute

$type : Types::*

the type which will be used to match a cast

Tags
since
31.0.0

Parameter $type is now restricted to Types constants. The formerly accidentally supported types 'int'|'bool'|'double' are mapped to Types::INTEGER|Types::BOOLEAN|Types::FLOAT accordingly.

since
7.0.0

getter()

Generic getter for properties

protected getter(string $name) : mixed
Parameters
$name : string
Tags
since
7.0.0

isGetterForBoolProperty()

protected isGetterForBoolProperty(string $methodName) : bool
Parameters
$methodName : string
Tags
since
18.0.0
Return values
bool

markFieldUpdated()

Mark am attribute as updated

protected markFieldUpdated(string $attribute) : void
Parameters
$attribute : string

the name of the attribute

Tags
since
7.0.0

setter()

Generic setter for properties

protected setter(string $name, array<string|int, mixed> $args) : void
Parameters
$name : string
$args : array<string|int, mixed>
Tags
throws
InvalidArgumentException
since
7.0.0

        
On this page

Search results