Generate links for use with HAL payloads
addHydrator(string $class, \Zend\Hydrator\HydratorInterface $hydrator) : \PhlyRestfully\Plugin\RestfulJsonRenderer
string
\Zend\Hydrator\HydratorInterface
\PhlyRestfully\Plugin\RestfulJsonRenderer
createCollection(\PhlyRestfully\HalCollection | array | object $collection, null | string $route) : \PhlyRestfully\HalCollection
null
string
createCollectionFromMetadata(object $object, \PhlyRestfully\Metadata $metadata) : \PhlyRestfully\HalCollection
createLink(string $route, null | false | int | string $id, null | mixed $resource) : string
Triggers the "createLink" event with the route, id, resource, and a set of params that will be passed to the route; listeners can alter any of the arguments, which will then be used by the method to generate the url.
string
null
false
int
string
null
mixed
string
createResource(\PhlyRestfully\HalResource | array | object $resource, string $route, string $identifierName) : \PhlyRestfully\HalResource
string
string
createResourceFromMetadata(object $object, \PhlyRestfully\Metadata $metadata) : \PhlyRestfully\HalResource | \PhlyRestfully\HalCollection
fromLinkCollection(\PhlyRestfully\LinkCollection $collection) : array
fromResource(\PhlyRestfully\LinkCollectionAwareInterface $resource) : array
getController() : \Zend\Stdlib\DispatchableInterface
\Zend\Stdlib\DispatchableInterface
getEventManager() : \Zend\EventManager\EventManagerInterface
Lazy-initializes one if none present.
\Zend\EventManager\EventManagerInterface
getHydratorForResource(object $resource) : \Zend\Hydrator\HydratorInterface | false
If the resource has a mapped hydrator, returns that hydrator. If not, and a default hydrator is present, the default hydrator is returned. Otherwise, a boolean false is returned.
object
\Zend\Hydrator\HydratorInterface
false
injectSelfLink(\PhlyRestfully\LinkCollectionAwareInterface $resource, string $route, string $identifier)
renderCollection(\PhlyRestfully\HalCollection $halCollection) : array | \PhlyRestfully\ApiProblem
Injects pagination links, if the composed collection is a Paginator, and then loops through the collection to create the data structure representing the collection.
For each resource in the collection, the event "renderCollection.resource" is triggered, with the following parameters:
This event can be useful particularly when you have multi-segment routes and wish to ensure that route parameters are injected, or if you want to inject query or fragment parameters.
Event parameters are aggregated in an ArrayObject, which allows you to directly manipulate them in your listeners:
$params = $e->getParams();
$params['routeOptions']['query'] = array('format' => 'json');
\PhlyRestfully\HalCollection
array
\PhlyRestfully\ApiProblem
Associative array representing the payload to render; returns ApiProblem if error in pagination occursrenderResource(\PhlyRestfully\HalResource $halResource) : array
Creates a hash representation of the HalResource. The resource is first converted to an array, and its associated links are injected as the "_links" member. If any members of the resource are themselves HalResource objects, they are extracted into an "_embedded" hash.
\PhlyRestfully\HalResource
array
setController(\Zend\Stdlib\DispatchableInterface $controller)
\Zend\Stdlib\DispatchableInterface
setDefaultHydrator(\Zend\Hydrator\HydratorInterface $hydrator) : \PhlyRestfully\Plugin\RestfulJsonRenderer
\Zend\Hydrator\HydratorInterface
\PhlyRestfully\Plugin\RestfulJsonRenderer
setEventManager(\Zend\EventManager\EventManagerInterface $events)
\Zend\EventManager\EventManagerInterface
setMetadataMap(\PhlyRestfully\MetadataMap $map) : \PhlyRestfully\Plugin\HalLinks
fluent | This method is part of a fluent interface and will return the same instance |
---|
setServerUrlHelper(\Zend\View\Helper\ServerUrl $helper)
\Zend\View\Helper\ServerUrl
setUrlHelper(\Zend\View\Helper\Url $helper)
\Zend\View\Helper\Url