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

Namespaces

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

Classes

  • Cache
  • Directives
  • Get
  • Model
  • Relationship

Class Directives

Implementation of directives

Phramework\JSONAPI\Model\Model
Extended by Phramework\JSONAPI\Model\Cache
Extended by Phramework\JSONAPI\Model\Directives

Direct known subclasses

Phramework\JSONAPI\Model\Get

Indirect known subclasses

Phramework\JSONAPI\Model, Phramework\JSONAPI\Model\Relationship

Abstract
Namespace: Phramework\JSONAPI\Model
License: Apache-2.0
Author: Xenofon Spafaridis nohponex@gmail.com
Since: 1.0.0
Located at Model/Directives.php

Methods summary

protected static string
# handleGet( string $query, Phramework\JSONAPI\Page $page = null, Phramework\JSONAPI\Filter $filter = null, Phramework\JSONAPI\Sort $sort = null, Phramework\JSONAPI\Fields $fields = null, boolean $hasWhere = true )

Apply page, filter, sort and fields directives to query. This method will replace {{table}}, {{sort}}, {{page}}, {{filter}} and {{fields}} in query.

Apply page, filter, sort and fields directives to query. This method will replace {{table}}, {{sort}}, {{page}}, {{filter}} and {{fields}} in query.

Parameters

$query
Query string
$page
See handlePage $page parameter
$filter
See handleFilter $filter parameter
$sort
See handleSort $sort parameter
$fields
See handleFields $fields parameter
$hasWhere
If query already has an WHERE, default is true

Returns

string
Query

Uses

static::handlePage
static::handleSort
static::handleFilter
static::handleFields

Example

$query = static::handleGet(
    'SELECT {{fields}}
     FROM "{{table}}"
     WHERE
       "{{table}}"."status" <> \'DISABLED\'
       {{filter}}
       {{sort}}
       {{page}}',
    $page,
    $filter,
    $sort,
    $fields,
    $page,
    true //query contains WHERE directive
);

protected static string
# handleFilter( string $query, Phramework\JSONAPI\Filter|null $filter = null, boolean $hasWhere = true )

This method will update {{filter}} string inside query parameter with the provided filter directives

This method will update {{filter}} string inside query parameter with the provided filter directives

Parameters

$query
Query
$filter
$hasWhere
[Optional] If query already has an WHERE directive, default is true

Returns

string
Query

Throws

Phramework\Exceptions\NotImplementedException
Exception

Todo

check if query work both in MySQL and postgreSQL

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

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