Ejemplo n.º 1
0
 /**
  * Transfrom claim into an array
  *
  * @param  Claim $claim
  * @return array
  * @throws \LogicException If $claim is not a Claim instance
  */
 public function toArray($claim)
 {
     if (!$claim instanceof Claim) {
         throw new \LogicException('ClaimArrayizer can only arrayize Claim objects');
     }
     return ['_id' => $claim->getId(), 'type' => 'wb:claim', 'title' => 'Ansökan ' . $claim->getId(), 'contact' => $this->contactArrayizer->toArray($claim->getContact()), 'account' => $this->accountArrayizer->toArray($claim->getAccountWrapper()), 'requested' => $claim->getRequestedAmount()->getAmount(), 'approved' => $claim->getApprovedAmount()->getAmount(), 'comment' => $claim->getComment(), 'created' => $claim->getCreated()->format(self::DATE_FORMAT), 'updated' => $claim->getUpdated()->format(self::DATE_FORMAT)];
 }
Ejemplo n.º 2
0
 public function getKey(Claim $claim)
 {
     return $claim->getContact()->getId();
 }
Ejemplo n.º 3
0
 public function getKey(Claim $claim)
 {
     return (string) $claim->getAccountWrapper()->getAccount();
 }
Ejemplo n.º 4
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()]));
 }