/** * Get the relative path of a file * @param \ride\library\system\file\File $file * @return string */ public function getRelativePath(File $file) { $relativePath = $file->getAbsolutePath(); foreach ($this->absolutePaths as $absolutePath) { if (strpos($relativePath, $absolutePath) === 0) { $relativePath = str_replace($absolutePath . '/', '', $relativePath); break; } } return $relativePath; }
/** * Reads the site revisions from the provided site directory * @param \ride\library\system\file\File $siteDirectory Directory of the site * @param string $defaultRevision Default revision for the site * @param string $revision Revision to load * @return array Array with the name of the revision as key and value * @throws \ride\library\cms\exception\CmsException when the site directory * could not be read */ protected function readSiteRevisions(File $siteDirectory, $defaultRevision, &$revision = null) { $revisions = array(); $files = $siteDirectory->read(); foreach ($files as $file) { $revision = $file->getName(true); if ($revision === $this->archiveName || $revision === $this->trashName || !$file->isDirectory()) { continue; } $revisions[$revision] = $revision; } if (!$revisions) { throw new CmsException('No valid site in ' . $siteDirectory->getAbsolutePath()); } if (isset($revisions[$defaultRevision])) { $revision = $defaultRevision; } else { $revision = reset($revisions); } return $revisions; }