/**
  * @param \databox $databox
  * @param string   $token
  * @param int      $record_id
  * @param string   $subdef
  * @return \record_adapter
  */
 private function retrieveRecord(\databox $databox, $token, $record_id, $subdef)
 {
     try {
         $record = new \record_adapter($this->app, $databox->get_sbas_id(), $record_id);
         $subDefinition = new \media_subdef($this->app, $record, $subdef);
         $permalink = new \media_Permalink_Adapter($this->app, $databox, $subDefinition);
     } catch (\Exception $exception) {
         throw new NotFoundHttpException('Wrong token.', $exception);
     }
     if (!$permalink->get_is_activated()) {
         throw new NotFoundHttpException('This token has been disabled.');
     }
     /** @var FeedItemRepository $feedItemsRepository */
     $feedItemsRepository = $this->app['repo.feed-items'];
     if (in_array($subdef, [\databox_subdef::CLASS_PREVIEW, \databox_subdef::CLASS_THUMBNAIL]) && $feedItemsRepository->isRecordInPublicFeed($databox->get_sbas_id(), $record_id)) {
         return $record;
     } elseif ($permalink->get_token() == (string) $token) {
         return $record;
     }
     throw new NotFoundHttpException('Wrong token.');
 }
示例#2
0
 public function testGet_token()
 {
     $this->assertInternalType('string', $this->object->get_token());
 }