class PostSerializer extends BasicPostSerializer

Properties

protected $request from AbstractSerializer
protected $actor from AbstractSerializer
static protected $container from AbstractSerializer
static protected array<string,callable[]> $attributeMutators from AbstractSerializer
static protected array<string,array<string,callable>> $customRelations from AbstractSerializer
protected $type from BasicPostSerializer

Methods

ServerRequestInterface
getRequest()

No description

void
setRequest(ServerRequestInterface $request)

No description

getActor()

No description

array
getAttributes(mixed $model, array $fields = null)

No description

array
getDefaultAttributes(object|array $model)

No description

string|null
formatDate(DateTime $date = null)

No description

getRelationship($model, $name)

No description

Relationship|null
getCustomRelationship(object|array $model, string $name)

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

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

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

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

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

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

No description

mixed
getRelationshipData(object|array $model, string $relation)

No description

SerializerInterface
resolveSerializer(SerializerInterface|Closure|string $serializer, object|array $model, mixed $data)

No description

object
resolveSerializerClass(string $class)

No description

static Container
getContainer()

No description

static void
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

__construct(LogReporter $log, TranslatorInterface $translator)

No description

Relationship|null
user(Post $post)

No description

Relationship|null
discussion(Post $post)

No description

Relationship|null
editedUser(Post $post)

No description

Relationship|null
hiddenUser(Post $post)

No description

Details

ServerRequestInterface getRequest()

Return Value

ServerRequestInterface

void setRequest(ServerRequestInterface $request)

Parameters

ServerRequestInterface $request

Return Value

void

User getActor()

Return Value

User

array getAttributes(mixed $model, array $fields = null)

Parameters

mixed $model
array $fields

Return Value

array

protected array getDefaultAttributes(object|array $model)

Parameters

object|array $model

Return Value

array

string|null formatDate(DateTime $date = null)

Parameters

DateTime $date

Return Value

string|null

getRelationship($model, $name)

Parameters

$model
$name

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

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

Parameters

object|array $model
string $name

Return Value

Relationship|null

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

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

Parameters

object|array $model
SerializerInterface|Closure|string $serializer
string $relation

Return Value

Relationship|null

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

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

Parameters

object|array $model
SerializerInterface|Closure|string $serializer
string $relation

Return Value

Relationship|null

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

Parameters

object|array $model
SerializerInterface|Closure|string $serializer
string $relation
bool $many

Return Value

Relationship|null

protected mixed getRelationshipData(object|array $model, string $relation)

Parameters

object|array $model
string $relation

Return Value

mixed

protected SerializerInterface resolveSerializer(SerializerInterface|Closure|string $serializer, object|array $model, mixed $data)

Parameters

SerializerInterface|Closure|string $serializer
object|array $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 void setContainer(Container $container)

Parameters

Container $container

Return Value

void

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

__construct(LogReporter $log, TranslatorInterface $translator)

Parameters

LogReporter $log
TranslatorInterface $translator

protected Relationship|null user(Post $post)

Parameters

Post $post

Return Value

Relationship|null

protected Relationship|null discussion(Post $post)

Parameters

Post $post

Return Value

Relationship|null

protected Relationship|null editedUser(Post $post)

Parameters

Post $post

Return Value

Relationship|null

protected Relationship|null hiddenUser(Post $post)

Parameters

Post $post

Return Value

Relationship|null