Ubiquity 2.5.2
php rapid development framework
Loading...
Searching...
No Matches
JsonApiResponseFormatter Class Reference

JsonAPI Formatter. More...

+ Inheritance diagram for JsonApiResponseFormatter:

Public Member Functions

 __construct ($baseRoute="")
 
 cleanRestObject ($o, &$classname=null)
 {Returns the array of attributes corresponding to an object $o.
Parameters
object$o
string$classname
Returns
array
}
 
 get ($objects, $pages=null)
 {Returns a formated JSON response for an array of objects $objects.
Parameters
array$objects
array | null$pages
Returns
string
}
 
 getOne ($object)
 
- Public Member Functions inherited from ResponseFormatter
 getDatas ($objects, &$classname=null)
 Returns an array of datas from an array of objects.
 
 getJSONDatas ($datas)
 
 format ($arrayResponse)
 Formats a response array.
 
 getModel ($controllerName)
 Returns the model name corresponding to $controlleName.
 
 toJson ($data)
 Formats an array of datas in JSON.
 
 formatException ($e)
 Returns a JSON representation of the exception $e.
 

Protected Member Functions

 addSelfLink (&$r, $pk, $frontClassname)
 
 addPageLinks (&$r, $classname, $pages)
 Adds page links.
 
 addRelationshipsLink (&$r, $pk, $pkMember, $frontClassname, $rFrontClassname, $member)
 

Private Member Functions

 getLink ($pattern, $params=[])
 
 getFrontClassname ($classname)
 

Private Attributes

 $selfLink = "%baseRoute%/%classname%/%id%/"
 
 $relationLink = "%baseRoute%/%classname%/%id%/%member%/"
 
 $pageLink = "%baseRoute%/%classname%/?page[number]=%pageNumber%&page[size]=%pageSize%"
 
 $baseRoute
 
 $_included
 

Additional Inherited Members

- Static Public Member Functions inherited from ResponseFormatter
static toXML ($data, &$xml_data)
 

Detailed Description

JsonAPI Formatter.

Ubiquity\controllers\rest\formatters$JsonApiResponseFormatter This class is part of Ubiquity

Author
jcheron myadd.nosp@m.ress.nosp@m.mail@.nosp@m.gmai.nosp@m.l.com
Version
1.1.1
Since
Ubiquity 2.0.11

Definition at line 18 of file JsonApiResponseFormatter.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $baseRoute = "")

Definition at line 25 of file JsonApiResponseFormatter.php.

Member Function Documentation

◆ addPageLinks()

addPageLinks ( $r,
  $classname,
  $pages 
)
protected

Adds page links.

Parameters
array$r
string$classname
array$pages

Definition at line 88 of file JsonApiResponseFormatter.php.

◆ addRelationshipsLink()

addRelationshipsLink ( $r,
  $pk,
  $pkMember,
  $frontClassname,
  $rFrontClassname,
  $member 
)
protected

Definition at line 96 of file JsonApiResponseFormatter.php.

◆ addSelfLink()

addSelfLink ( $r,
  $pk,
  $frontClassname 
)
protected

Definition at line 77 of file JsonApiResponseFormatter.php.

◆ cleanRestObject()

cleanRestObject (   $o,
$classname = null 
)

{Returns the array of attributes corresponding to an object $o.

Parameters
object$o
string$classname
Returns
array
}

See also
\Ubiquity\controllers\rest\formatters\ResponseFormatter::cleanRestObject()

Reimplemented from ResponseFormatter.

Definition at line 34 of file JsonApiResponseFormatter.php.

◆ get()

get (   $objects,
  $pages = null 
)

{Returns a formated JSON response for an array of objects $objects.

Parameters
array$objects
array | null$pages
Returns
string
}

See also
\Ubiquity\controllers\rest\formatters\ResponseFormatter::get()

Reimplemented from ResponseFormatter.

Definition at line 117 of file JsonApiResponseFormatter.php.

◆ getFrontClassname()

getFrontClassname (   $classname)
private

Definition at line 108 of file JsonApiResponseFormatter.php.

◆ getLink()

getLink (   $pattern,
  $params = [ ] 
)
private

Definition at line 100 of file JsonApiResponseFormatter.php.

◆ getOne()

getOne (   $object)
Parameters
object$object
Returns
string

Reimplemented from ResponseFormatter.

Definition at line 134 of file JsonApiResponseFormatter.php.

Field Documentation

◆ $_included

$_included
private

Definition at line 23 of file JsonApiResponseFormatter.php.

◆ $baseRoute

$baseRoute
private

Definition at line 22 of file JsonApiResponseFormatter.php.

◆ $pageLink

$pageLink = "%baseRoute%/%classname%/?page[number]=%pageNumber%&page[size]=%pageSize%"
private

Definition at line 21 of file JsonApiResponseFormatter.php.

◆ $relationLink

$relationLink = "%baseRoute%/%classname%/%id%/%member%/"
private

Definition at line 20 of file JsonApiResponseFormatter.php.

◆ $selfLink

$selfLink = "%baseRoute%/%classname%/%id%/"
private

Definition at line 19 of file JsonApiResponseFormatter.php.


The documentation for this class was generated from the following file: