/**
  * @param BadgeAssertion $badgeAssertion
  * @return array
  */
 public function badgeAssertionToArray(BadgeAssertion $badgeAssertion)
 {
     $badgeClassUri = $this->controllerContext->getUriBuilder()->reset()->setCreateAbsoluteUri(TRUE)->setFormat('json')->uriFor('show', array('badgeClass' => $badgeAssertion->getBadgeClass()), 'BadgeClass');
     $badgeAssertionUri = $this->controllerContext->getUriBuilder()->reset()->setCreateAbsoluteUri(TRUE)->setFormat('json')->uriFor('show', array('badgeAssertion' => $badgeAssertion), 'BadgeAssertion');
     $badgeAssertionIdentifier = $this->persistenceManager->getIdentifierByObject($badgeAssertion);
     return array('uid' => $badgeAssertionIdentifier, 'recipient' => $badgeAssertion->getIdentityObject(), 'badge' => $badgeClassUri, 'verify' => array('type' => 'hosted', 'url' => $badgeAssertionUri), 'issuedOn' => $badgeAssertion->getIssuedOn()->format('c'));
 }
 /**
  * @param BadgeClass $badgeClass
  * @param string $recipientEmail
  * @param array<string> $tokens
  */
 public function createAction(BadgeClass $badgeClass, $recipientEmail, array $tokens)
 {
     if ($this->badgeAsserter->validateAndClearAssertionSteps($badgeClass, $tokens)) {
         $badgeAssertion = new BadgeAssertion();
         $badgeAssertion->setBadgeClass($badgeClass);
         $badgeAssertion->setIssuedOn(new \DateTime());
         $badgeAssertion->setRecipientEmail($recipientEmail);
         $this->badgeAssertionRepository->add($badgeAssertion);
         $this->view->assign('value', $badgeAssertion);
         $this->response->setStatus(201);
     } else {
         $this->view->assign('error', array('message' => 'A required assertion step for this badge was not completed', 'code' => 'MissingAssertionStep'));
         $this->response->setStatus(403);
     }
 }