getPageVersionByUniqueId() public method

Get the information about a particular page version, given a unique ID
public getPageVersionByUniqueId ( string $uniqueId ) : array
$uniqueId string
return array
Beispiel #1
0
 /**
  * We're going to view a page's history
  *
  * @route pages/{string}/history/view/{string}
  * @param string $cabin
  * @param string $uniqueId
  */
 public function pageHistoryView(string $cabin, string $uniqueId)
 {
     $page = [];
     $version = [];
     $path = $this->determinePath($cabin);
     if (!\is1DArray($_GET)) {
         \Airship\redirect($this->airship_cabin_prefix . '/pages/' . \trim($cabin, '/'));
     }
     $cabins = $this->getCabinNamespaces();
     if (!\in_array($cabin, $cabins)) {
         \Airship\redirect($this->airship_cabin_prefix);
     }
     $this->setTemplateExtraData($cabin);
     if (!$this->can('read')) {
         \Airship\redirect($this->airship_cabin_prefix);
     }
     try {
         $version = $this->pg->getPageVersionByUniqueId($uniqueId);
         if (!empty($version['metadata'])) {
             $version['metadata'] = \json_decode($version['metadata'], true);
         }
         $page = $this->pg->getPageById($version['page']);
     } catch (CustomPageNotFoundException $ex) {
         \Airship\redirect($this->airship_cabin_prefix . '/pages/' . \trim($cabin, '/'));
     }
     $prevUnique = $this->pg->getPrevVersionUniqueId((int) $version['page'], $version['versionid']);
     $nextUnique = $this->pg->getNextVersionUniqueId((int) $version['page'], $version['versionid']);
     $latestId = $this->pg->getLatestVersionId((int) $version['page']);
     $this->lens('pages/page_history_view', ['cabins' => $cabins, 'pageinfo' => $page, 'version' => $version, 'latestId' => $latestId, 'prev_url' => $prevUnique, 'next_url' => $nextUnique, 'dir' => $path, 'cabin' => $cabin, 'pathinfo' => \Airship\chunk($path)]);
 }