コード例 #1
0
 /**
  * @param DocumentLink $link
  *
  * @return null|string
  */
 public function resolve($link)
 {
     if ($link->isBroken()) {
         return null;
     }
     return "http://host/doc/" . $link->getId();
 }
コード例 #2
0
 /**
  * @param DocumentLink $link
  *
  * @return string
  */
 public function resolve($link)
 {
     return $this->urlGenerator->generate('detail', array('id' => $link->getId(), 'slug' => $link->getSlug()));
 }
コード例 #3
0
ファイル: LinkResolver.php プロジェクト: cjunge-work/php-kit
 /**
  * Returns true if the given document link corresponds to the given bookmark
  *
  * @param API          $api      The API
  * @param DocumentLink $link     The document link to test
  * @param string       $bookmark The bookmark to test
  *
  * @return true if the given document corresponds to the given bookmark
  */
 public function isBookmark($api, $link, $bookmark)
 {
     $maybeId = $api->bookmark($bookmark);
     if ($maybeId == $link->getId()) {
         return true;
     }
     return false;
 }
コード例 #4
0
 /**
  * Create Prismic specific Route Paramters from the given Document Link according to routing options
  * @param  DocumentLink $link
  * @return array
  */
 public function getRouteParams(DocumentLink $link)
 {
     $document = $this->getContext()->getDocumentById($link->getId());
     $bookmark = $this->getContext()->findBookmarkByDocument($document);
     return array($this->routerOptions->getIdParam() => $link->getId(), $this->routerOptions->getUidParam() => $link->getUid(), $this->routerOptions->getMaskParam() => $document->getType(), $this->routerOptions->getBookmarkParam() => $bookmark, $this->routerOptions->getRefParam() => $this->getContext()->getRefAsString(), $this->routerOptions->getSlugParam() => $document->getSlug());
 }