abstract class AbstractSerializer extends AbstractSerializer

Properties

protected ServerRequestInterface $request
protected User $actor
static protected Container $container
static protected array<string,callable[]> $attributeMutators
static protected array<string,array<string,callable>> $customRelations

Methods

ServerRequestInterface
getRequest()

No description

setRequest(ServerRequestInterface $request)

No description

getActor()

No description

getAttributes($model, array $fields = null)

<p>{@inheritdoc}</p>

array
getDefaultAttributes(object|array $model)

<p>Get the default set of serialized attributes for a model.</p>

string|null
formatDate(DateTime $date = null)

No description

getRelationship($model, $name)

<p>{@inheritdoc}</p>

Relationship|null
getCustomRelationship(mixed $model, string $name)

<p>Get a custom relationship.</p>

Relationship
hasOne(mixed $model, string|Closure|SerializerInterface $serializer, string|Closure|null $relation = null)

<p>Get a relationship builder for a has-one relationship.</p>

Relationship
hasMany(mixed $model, string|Closure|SerializerInterface $serializer, string|null $relation = null)

<p>Get a relationship builder for a has-many relationship.</p>

Relationship|null
buildRelationship(mixed $model, string|Closure|SerializerInterface $serializer, string|null $relation = null, bool $many = false)

No description

mixed
getRelationshipData(mixed $model, string $relation)

No description

SerializerInterface
resolveSerializer(mixed $serializer, mixed $model, mixed $data)

No description

object
resolveSerializerClass(string $class)

No description

static Container
getContainer()

No description

static 
setContainer(Container $container)

No description

static void
addAttributeMutator(string $serializerClass, callable $callback)

No description

static void
setRelationship(string $serializerClass, string $relation, callable $callback)

No description

Details

ServerRequestInterface getRequest()

Return Value

ServerRequestInterface

setRequest(ServerRequestInterface $request)

Parameters

ServerRequestInterface $request

User getActor()

Return Value

User

getAttributes($model, array $fields = null)

<p>{@inheritdoc}</p>

Parameters

$model
array $fields

abstract protected array getDefaultAttributes(object|array $model)

<p>Get the default set of serialized attributes for a model.</p>

Parameters

object|array $model

Return Value

array

string|null formatDate(DateTime $date = null)

Parameters

DateTime $date

Return Value

string|null

getRelationship($model, $name)

<p>{@inheritdoc}</p>

Parameters

$model
$name

protected Relationship|null getCustomRelationship(mixed $model, string $name)

<p>Get a custom relationship.</p>

Parameters

mixed $model
string $name

Return Value

Relationship|null

Relationship hasOne(mixed $model, string|Closure|SerializerInterface $serializer, string|Closure|null $relation = null)

<p>Get a relationship builder for a has-one relationship.</p>

Parameters

mixed $model
string|Closure|SerializerInterface $serializer
string|Closure|null $relation

Return Value

Relationship

Relationship hasMany(mixed $model, string|Closure|SerializerInterface $serializer, string|null $relation = null)

<p>Get a relationship builder for a has-many relationship.</p>

Parameters

mixed $model
string|Closure|SerializerInterface $serializer
string|null $relation

Return Value

Relationship

protected Relationship|null buildRelationship(mixed $model, string|Closure|SerializerInterface $serializer, string|null $relation = null, bool $many = false)

Parameters

mixed $model
string|Closure|SerializerInterface $serializer
string|null $relation
bool $many

Return Value

Relationship|null

protected mixed getRelationshipData(mixed $model, string $relation)

Parameters

mixed $model
string $relation

Return Value

mixed

protected SerializerInterface resolveSerializer(mixed $serializer, mixed $model, mixed $data)

Parameters

mixed $serializer
mixed $model
mixed $data

Return Value

SerializerInterface

Exceptions

InvalidArgumentException

protected object resolveSerializerClass(string $class)

Parameters

string $class

Return Value

object

static Container getContainer()

Return Value

Container

static setContainer(Container $container)

Parameters

Container $container

static void addAttributeMutator(string $serializerClass, callable $callback)

Parameters

string $serializerClass
callable $callback

Return Value

void

static void setRelationship(string $serializerClass, string $relation, callable $callback)

Parameters

string $serializerClass
string $relation
callable $callback

Return Value

void