PHP Class Flarum\Api\Serializer\AbstractSerializer

Inheritance: extends Tobscure\JsonApi\AbstractSerializer
Show file Open project: flarum/core Class Usage Examples

Protected Properties

Property Type Description
$actor Flarum\Core\User
$container Illuminate\Contracts\Container\Container
$dispatcher Illuminate\Contracts\Events\Dispatcher

Public Methods

Method Description
getActor ( ) : User
getAttributes ( $model, array $fields = null )
getContainer ( ) : Illuminate\Contracts\Container\Container
getEventDispatcher ( ) : Illuminate\Contracts\Events\Dispatcher
getRelationship ( $model, $name )
hasMany ( mixed $model, string | Closur\Closure | Tobscure\JsonApi\SerializerInterface $serializer, string | null $relation = null ) : Relationship Get a relationship builder for a has-many relationship.
hasOne ( mixed $model, string | Closur\Closure | Tobscure\JsonApi\SerializerInterface $serializer, string | Closur\Closure | null $relation = null ) : Relationship Get a relationship builder for a has-one relationship.
setActor ( User $actor )
setContainer ( Illuminate\Contracts\Container\Container $container )
setEventDispatcher ( Illuminate\Contracts\Events\Dispatcher $dispatcher )

Protected Methods

Method Description
buildRelationship ( mixed $model, string | Closur\Closure | Tobscure\JsonApi\SerializerInterface $serializer, string | null $relation = null, boolean $many = false ) : Relationship
formatDate ( DateTime $date = null ) : string | null
getCustomRelationship ( mixed $model, string $name ) : Relationship | null Get a custom relationship.
getDefaultAttributes ( object | array $model ) : array Get the default set of serialized attributes for a model.
getRelationshipData ( mixed $model, $relation ) : mixed
resolveSerializer ( mixed $serializer, mixed $model, mixed $data ) : Tobscure\JsonApi\SerializerInterface
resolveSerializerClass ( string $class ) : object

Method Details

buildRelationship() protected method

protected buildRelationship ( mixed $model, string | Closur\Closure | Tobscure\JsonApi\SerializerInterface $serializer, string | null $relation = null, boolean $many = false ) : Relationship
$model mixed
$serializer string | Closur\Closure | Tobscure\JsonApi\SerializerInterface
$relation string | null
$many boolean
return Tobscure\JsonApi\Relationship

formatDate() protected method

protected formatDate ( DateTime $date = null ) : string | null
$date DateTime
return string | null

getActor() public method

public getActor ( ) : User
return Flarum\Core\User

getAttributes() public method

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

getContainer() public static method

public static getContainer ( ) : Illuminate\Contracts\Container\Container
return Illuminate\Contracts\Container\Container

getCustomRelationship() protected method

Get a custom relationship.
protected getCustomRelationship ( mixed $model, string $name ) : Relationship | null
$model mixed
$name string
return Tobscure\JsonApi\Relationship | null

getDefaultAttributes() abstract protected method

Get the default set of serialized attributes for a model.
abstract protected getDefaultAttributes ( object | array $model ) : array
$model object | array
return array

getEventDispatcher() public static method

public static getEventDispatcher ( ) : Illuminate\Contracts\Events\Dispatcher
return Illuminate\Contracts\Events\Dispatcher

getRelationship() public method

public getRelationship ( $model, $name )

getRelationshipData() protected method

protected getRelationshipData ( mixed $model, $relation ) : mixed
$model mixed
return mixed

hasMany() public method

Get a relationship builder for a has-many relationship.
public hasMany ( mixed $model, string | Closur\Closure | Tobscure\JsonApi\SerializerInterface $serializer, string | null $relation = null ) : Relationship
$model mixed
$serializer string | Closur\Closure | Tobscure\JsonApi\SerializerInterface
$relation string | null
return Tobscure\JsonApi\Relationship

hasOne() public method

Get a relationship builder for a has-one relationship.
public hasOne ( mixed $model, string | Closur\Closure | Tobscure\JsonApi\SerializerInterface $serializer, string | Closur\Closure | null $relation = null ) : Relationship
$model mixed
$serializer string | Closur\Closure | Tobscure\JsonApi\SerializerInterface
$relation string | Closur\Closure | null
return Tobscure\JsonApi\Relationship

resolveSerializer() protected method

protected resolveSerializer ( mixed $serializer, mixed $model, mixed $data ) : Tobscure\JsonApi\SerializerInterface
$serializer mixed
$model mixed
$data mixed
return Tobscure\JsonApi\SerializerInterface

resolveSerializerClass() protected method

protected resolveSerializerClass ( string $class ) : object
$class string
return object

setActor() public method

public setActor ( User $actor )
$actor Flarum\Core\User

setContainer() public static method

public static setContainer ( Illuminate\Contracts\Container\Container $container )
$container Illuminate\Contracts\Container\Container

setEventDispatcher() public static method

public static setEventDispatcher ( Illuminate\Contracts\Events\Dispatcher $dispatcher )
$dispatcher Illuminate\Contracts\Events\Dispatcher

Property Details

$actor protected property

protected User,Flarum\Core $actor
return Flarum\Core\User

$container protected static property

protected static Container,Illuminate\Contracts\Container $container
return Illuminate\Contracts\Container\Container

$dispatcher protected static property

protected static Dispatcher,Illuminate\Contracts\Events $dispatcher
return Illuminate\Contracts\Events\Dispatcher