Ejemplo n.º 1
0
 /**
  * Create resource wrapping claim
  *
  * @param  Claim    $claim
  * @param  string   $selfRoute  Name of route to generate self link from
  * @param  string[] $selfParams Route params to use when generating self link
  * @return Resource
  */
 public function createClaimResource(Claim $claim, $selfRoute = 'claims.item.read', array $selfParams = [])
 {
     $selfParams = $selfParams ?: ['id' => $claim->getId()];
     $resource = new Resource($this->generator->generate($selfRoute, $selfParams), $this->claimArrayizer->toArray($claim));
     return $resource->addLink('edit', $this->generator->generate('claims.item.read', ['id' => $claim->getId()]))->addLink('collection', $this->generator->generate('claims.coll.read'))->addLink('wb:contact', $this->generator->generate('contacts.item.read', ['id' => $claim->getContact()->getId()]));
 }
Ejemplo n.º 2
0
 public function createResponse(Payload $payload)
 {
     $resource = new Hal\Resource($this->generator->generate('manifest'), ['type' => 'wb:manifest', 'title' => 'Förstasidan', 'name' => $this->settings->read('app.name'), 'version' => $this->settings->read('app.version'), 'deploy' => $this->settings->read('app.deploy'), 'runtime' => phpversion()]);
     $resource->addLink('wb:contact-collection', $this->generator->generate('contacts.coll.read'));
     return new Hal\Response($resource);
 }