Пример #1
0
 /**
  * Return this object's current revision
  *
  * @return Revision Current revision
  */
 protected function getCurrentRevision()
 {
     if ($this->latestRevision->isDraft() && $this->latestRevision->getRevision() > 1) {
         return Kernel::create(Revision::class, [$this->latestRevision->getRevision() - 1, false]);
     }
     return $this->latestRevision;
 }
Пример #2
0
 /**
  * Serialize as relative URL
  *
  * @param bool $canonical Canonical URL
  * @return string Relative URL
  */
 public function toUrl($canonical = false)
 {
     $locator = [];
     $datePrecision = intval(getenv('OBJECT_DATE_PRECISION'));
     // Add the creation date
     foreach (array_slice(array_keys(self::$datePattern), 0, $datePrecision) as $dateFormat) {
         $locator[] = $this->creationDate->format($dateFormat);
     }
     // Add the object ID and type
     $uid = $this->uid->getId();
     $locator[] = ($this->hidden ? '.' : '') . $uid;
     // If not only the canonical URL should be returned
     if (!$canonical) {
         $locator[count($locator) - 1] .= '-' . $this->type->getType();
         // Add the ID, draft mode and revision
         $locator[] = rtrim(($this->revision->isDraft() ? '.' : '') . $uid . '-' . $this->revision->getRevision(), '-');
     }
     return '/' . implode('/', $locator);
 }
Пример #3
0
 /**
  * Compare this revision to a given one
  *
  * @param Revision $revision Comparison revision
  * @return bool This revision equals the given one
  */
 public function equals(Revision $revision)
 {
     return $this->revision == $revision->getRevision() && $this->draft == $revision->isDraft();
 }