https://github.com/dazz/hypermedia
This project shows an example on how to add hypermedia to an object.
https://github.com/dazz/hypermedia
Last synced: about 1 year ago
JSON representation
This project shows an example on how to add hypermedia to an object.
- Host: GitHub
- URL: https://github.com/dazz/hypermedia
- Owner: dazz
- Created: 2013-07-07T09:49:20.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2022-03-26T00:37:07.000Z (over 4 years ago)
- Last Synced: 2025-03-24T16:01:47.333Z (over 1 year ago)
- Language: PHP
- Homepage:
- Size: 17.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
hypermedia
==========
This project shows an example on how to add hypermedia to an object.
See tests how to set it up and build hypermedia.
Example:
```php
# set up the POPO
$object = new fixtures\Person();
$object->setId(1);
$object->setGroupId(1);
# Resource holds information about possible links
$resource = new fixtures\PersonResource();
# The project comes with a SimpleVoter if none is set
# It can be implemented to vote on showing links or not depending on token role
$securityToken = new fixtures\SecurityToken('anonymously');
$voter = new fixtures\Voter();
$builder = Builder::createBuilder($voter, $securityToken);
$output = $builder->build($resource, $object);
```
Output:
```php
Array
(
[0] => Array
(
[href] => /user
[rel] => users
)
[1] => Array
(
[href] => /groups/1
[rel] => group
)
)
```