phramework/jsonapi doc
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo

Namespaces

  • Phramework
    • JSONAPI
      • Controller
        • POST
      • Model
      • Viewers

Classes

  • Controller
  • Fields
  • Filter
  • FilterAttribute
  • FilterJSONAttribute
  • Model
  • Page
  • Relationship
  • RelationshipResource
  • Resource
  • Sort
  • Util
  • ValidationModel

Class Resource

stdClass
Extended by Phramework\JSONAPI\Resource implements JsonSerializable

Direct known subclasses

Phramework\JSONAPI\RelationshipResource

Namespace: Phramework\JSONAPI
License: Apache-2.0
Author: Xenofon Spafaridis nohponex@gmail.com
Since: 1.0.0
Todo:

add magic set and get, set will instantiate a property if it's null, to reduce output of json to minimal required


Located at Resource.php

Methods summary

public
# __construct( string $type, string $id )

Resource constructor.

Resource constructor.

Parameters

$type
$id
public
# __set( $name, $value )
public mixed
# __get( string $name )

Parameters

$name

Returns

mixed

Throws

Exception
public static
# parseFromRecords( $records, $modelClass, Phramework\JSONAPI\Fields $fields = null, $flags = Resource::PARSE_DEFAULT )
public static Phramework\JSONAPI\Resource|null
# parseFromRecord( array|object $record, string $modelClass, Phramework\JSONAPI\Fields $fields = null, $flags = Resource::PARSE_DEFAULT )

Parameters

$record
$modelClass
$fields
$flags

Returns

Phramework\JSONAPI\Resource|null

Throws

Exception

Example

Resource::parseFromRecord(
    [
        'id'     => '1',
        'status' => 'enabled',
        'title'  => 'blog'
    ],
    Tag::class
);

Todo

what about getRelationshipData method ?
public
# jsonSerialize( )

Implementation of

JsonSerializable::jsonSerialize()

Constants summary

string META_MEMBER
# 'attributes-meta'
integer PARSE_DEFAULT
# 15
integer PARSE_ATTRIBUTES
# 1
integer PARSE_LINKS
# 2
integer PARSE_RELATIONSHIP
# 4
integer PARSE_RELATIONSHIP_LINKS
# 8
integer PARSE_RELATIONSHIP_DATA
# 16
integer PARSE_META

Deprecated

# 128

Properties summary

protected string $type

Resource's type

Resource's type

#
protected string $id

NOTE The id member is not required when the resource object originates at the client and represents a new resource to be created on the server.

NOTE The id member is not required when the resource object originates at the client and represents a new resource to be created on the server.

#

Magic properties

public string $links
public string $attributes
public string $relationships
public string $data
public read-only string $id
public read-only string $type
phramework/jsonapi doc API documentation generated by ApiGen