-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
73 changed files
with
2,663 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
use alsvanzelf\jsonapi\CollectionDocument; | ||
use alsvanzelf\jsonapi\objects\ResourceObject; | ||
use alsvanzelf\jsonapi\profiles\CursorPaginationProfile; | ||
|
||
require 'bootstrap_examples.php'; | ||
|
||
/** | ||
* use the cursor pagination profile as extension to the document | ||
*/ | ||
|
||
$profile = new CursorPaginationProfile(); | ||
|
||
$user1 = new ResourceObject('user', 1); | ||
$user2 = new ResourceObject('user', 2); | ||
$user42 = new ResourceObject('user', 42); | ||
|
||
$profile->setCursor($user1, 'ford'); | ||
$profile->setCursor($user2, 'arthur'); | ||
$profile->setCursor($user42, 'zaphod'); | ||
|
||
$document = CollectionDocument::fromResources($user1, $user2, $user42); | ||
$document->applyProfile($profile); | ||
|
||
$profile->setCount($document, $exactTotal=3, $bestGuessTotal=10); | ||
$profile->setLinksFirstPage($document, $currentUrl='/users?sort=42&page[size]=10', $lastCursor='zaphod'); | ||
|
||
/** | ||
* get the json | ||
*/ | ||
|
||
$options = [ | ||
'prettyPrint' => true, | ||
]; | ||
echo '<pre>'.$document->toJson($options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
use alsvanzelf\jsonapi\ResourceDocument; | ||
|
||
require 'bootstrap_examples.php'; | ||
|
||
/** | ||
* use a profile as extension to the document | ||
* | ||
* allowing to define aliases for the keywords to solve conflicts between different profiles | ||
*/ | ||
|
||
$profile = new ExampleVersionProfile(['version' => 'ref']); | ||
|
||
$document = new ResourceDocument('user', 42); | ||
$document->applyProfile($profile); | ||
|
||
/** | ||
* you can apply the rules of the profile manually | ||
* or use methods of the profile if provided | ||
*/ | ||
|
||
$profile->setVersion($document, '2019'); | ||
|
||
/** | ||
* get the json | ||
*/ | ||
|
||
$options = [ | ||
'prettyPrint' => true, | ||
]; | ||
echo '<pre>'.$document->toJson($options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.