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 Model

Base JSONAPI Model

Phramework\JSONAPI\Model\Model
Extended by Phramework\JSONAPI\Model\Cache
Extended by Phramework\JSONAPI\Model\Directives
Extended by Phramework\JSONAPI\Model\Get
Extended by Phramework\JSONAPI\Model\Relationship
Extended by Phramework\JSONAPI\Model
Abstract
Namespace: Phramework\JSONAPI
License: Apache-2.0
Author: Xenofon Spafaridis nohponex@gmail.com
Since: 0.0.0
Located at Model.php

Methods summary

public static Phramework\JSONAPI\ValidationModel
# getValidationModel( )

Get resource's validation model

Get resource's validation model

Returns

Phramework\JSONAPI\ValidationModel
public static Phramework\Validate\ObjectValidator
# getFilterValidationModel( )

Get validation model used for filters, if set for a property, this will override the validation model defined in getValidationModel for this property

Get validation model used for filters, if set for a property, this will override the validation model defined in getValidationModel for this property

Returns

Phramework\Validate\ObjectValidator
public static Phramework\JSONAPI\Resource[]
# collection( array[]|object[] $records = [], Phramework\JSONAPI\Fields $fields = null, $flags = Resource::PARSE_DEFAULT )

Prepare a collection of resources

Prepare a collection of resources

Parameters

$records

Multiple records fetched from database [Optional] Write resource and relationship links, defaults is false

$fields
$flags

Returns

Phramework\JSONAPI\Resource[]

Uses

Resource::parseFromRecords

Todo

Add example
public static Phramework\JSONAPI\Resource|null
# resource( array|object $record, Phramework\JSONAPI\Fields $fields = null, $flags = Resource::PARSE_DEFAULT )

Prepare an individual resource

Prepare an individual resource

Parameters

$record
A single record fetched from database
$fields
$flags

Returns

Phramework\JSONAPI\Resource|null

Throws

Exception

Uses

Resource::parseFromRecord

Todo

Add example
public static mixed
# post( array $attributes, Phramework\Database\Operations\Create::RETURN_ID $return = Phramework\Phramework\Database\Operations\Create::RETURN_ID )

Create a record in database

Create a record in database

Parameters

$attributes
$return

Return type, default is RETURN_ID

Returns

mixed

Todo

disable post ?
public static integer
# patch( mixed $id, object $attributes )

Update selected attributes of a database record

Update selected attributes of a database record

Parameters

$id
id attribute's value
$attributes
Key-value array with fields to update

Returns

integer
Number of updated rows

Todo

add query limit
public static boolean
# delete( mixed $id, object $additionalAttributes = null )

Delete a database record

Delete a database record

Parameters

$id
id attribute's value
$additionalAttributes

Object with additional fields to use in WHERE clause

Returns

boolean
Returns true on success, false on failure
public static object
# getFilterable( )

Get filterable attribute keys MAY be overwritten

Get filterable attribute keys MAY be overwritten

Returns

object

Example

$filterable = getFilterable();

//Will return
(object) [
    'no-validator' => Operator::CLASS_COMPARABLE,
    'status'       => Operator::CLASS_COMPARABLE,
    'title'        => Operator::CLASS_COMPARABLE | Operator::CLASS_LIKE,
]

public static string[]
# getMutable( )

Get attribute keys that can be updated using PATCH MAY be overwritten

Get attribute keys that can be updated using PATCH MAY be overwritten

Returns

string[]
public static string[]
# getSortable( )

Get attribute keys that allowed to be used for sort MAY be overwritten

Get attribute keys that allowed to be used for sort MAY be overwritten

Returns

string[]

Since

1.0.0
public static string[]
# getFields( )

Get attribute keys that allowed to be used for sort MAY be overwritten

Get attribute keys that allowed to be used for sort MAY be overwritten

Returns

string[]

Since

1.0.0
public static Phramework\JSONAPI\Fields
# getDefaultFields( )

Get default fields for this resource model MAY be overwritten, default is 'table.*'] where table is accessed from this resource model's table

Get default fields for this resource model MAY be overwritten, default is 'table.*'] where table is accessed from this resource model's table

Returns

Phramework\JSONAPI\Fields

Since

1.0.0
public static Phramework\JSONAPI\Page
# getDefaultPage( )

Get default page for this resource model MAY be overwritten, default is with limit of 250 resource and offset 0

Get default page for this resource model MAY be overwritten, default is with limit of 250 resource and offset 0

Returns

Phramework\JSONAPI\Page

Since

1.0.0

Todo

make current applied page somehow visible at meta
public static Phramework\JSONAPI\Sort
# getSort( )

Get sort MAY be overwritten, default is sorting by id attribute ascending

Get sort MAY be overwritten, default is sorting by id attribute ascending

Returns

Phramework\JSONAPI\Sort
public static integer
# getMaxPageLimit( )

Get maximum page object's limit MAY be overwritten, default is with limit maximum of 25000

Get maximum page object's limit MAY be overwritten, default is with limit maximum of 25000

Returns

integer

Methods inherited from Phramework\JSONAPI\Model\Relationship

getIncludedData(), getRelationship(), getRelationshipData(), getRelationships(), relationshipExists()

Methods inherited from Phramework\JSONAPI\Model\Get

get(), getById(), parseFields(), parseFilter(), parsePage(), parseSort()

Methods inherited from Phramework\JSONAPI\Model\Directives

handleFilter(), handleGet()

Methods inherited from Phramework\JSONAPI\Model\Cache

getCache(), initializeCache(), invalidateCache(), setCache()

Methods inherited from Phramework\JSONAPI\Model\Model

getCast(), getEndpoint(), getIdAttribute(), getSchema(), getSelfLink(), getTable(), getType()

Constants summary

Constants inherited from Phramework\JSONAPI\Model\Model

GET_BY_PREFIX, GET_RELATIONSHIP_BY_PREFIX, POST_RELATIONSHIP_BY_PREFIX

Properties summary

protected static boolean $caching

Enable caching of resources

Enable caching of resources

# true

Properties inherited from Phramework\JSONAPI\Model\Cache

$cache

Properties inherited from Phramework\JSONAPI\Model\Model

$cast, $endpoint, $idAttribute, $schema, $table, $type

phramework/jsonapi doc API documentation generated by ApiGen