/**
  * @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
文件: V1.php 项目: nlegoff/Phraseanet
 /**
  * Retrieve detailled information about one permalink
  *
  * @param media_Permalink_Adapter $permalink
  *
  * @return type
  */
 private function list_permalink(\media_Permalink_Adapter $permalink)
 {
     $downloadUrl = $permalink->get_url();
     $downloadUrl->getQuery()->set('download', '1');
     return ['created_on' => $permalink->get_created_on()->format(DATE_ATOM), 'id' => $permalink->get_id(), 'is_activated' => $permalink->get_is_activated(), 'label' => $permalink->get_label(), 'updated_on' => $permalink->get_last_modified()->format(DATE_ATOM), 'page_url' => $permalink->get_page(), 'download_url' => (string) $downloadUrl, 'url' => (string) $permalink->get_url()];
 }
示例#3
0
 public function testGet_is_activated()
 {
     $this->assertInternalType('boolean', $this->object->get_is_activated());
 }
示例#4
0
 /**
  * Retrieve detailled information about one permalink
  *
  * @param media_Permalink_Adapter $permalink
  *
  * @return type
  */
 protected function list_permalink(media_Permalink_Adapter $permalink)
 {
     return ['created_on' => $permalink->get_created_on()->format(DATE_ATOM), 'id' => $permalink->get_id(), 'is_activated' => $permalink->get_is_activated(), 'label' => $permalink->get_label(), 'updated_on' => $permalink->get_last_modified()->format(DATE_ATOM), 'page_url' => $permalink->get_page(), 'download_url' => $permalink->get_url() . '&download', 'url' => $permalink->get_url()];
 }