コード例 #1
0
ファイル: GitRepository.php プロジェクト: terretta/gitki.php
 public function __construct($repositoryPath)
 {
     $pathString = $repositoryPath;
     if (!StringUtils::startsWith($pathString, '/')) {
         throw new \Exception('Repository Path must be absolute');
     }
     if (!StringUtils::endsWith($pathString, '/')) {
         $pathString .= '/';
     }
     $this->repositoryPath = DirectoryPath::parse($pathString);
 }
コード例 #2
0
 protected function targetUrlExists($url)
 {
     try {
         $urlParts = parse_url($url);
         $urlPath = $urlParts['path'];
         $path = null;
         if (StringUtils::startsWith($urlPath, '/')) {
             /* Absolute paths won't work */
             return false;
         } else {
             $directoryPath = $this->path->getParentPath();
             $path = $directoryPath->appendPathString($urlPath);
         }
         $fileExists = $this->repository->exists($path);
         $this->linkedPaths[] = $path;
         return $fileExists;
     } catch (\Exception $e) {
     }
     return true;
 }
コード例 #3
0
ファイル: WikiController.php プロジェクト: terretta/gitki.php
 /**
  * @param Request $request
  * @param string  $path
  *
  * @throws AccessDeniedHttpException
  */
 protected function checkPreconditions(Request $request, $path)
 {
     if (StringUtils::startsWith($path, '/.git')) {
         throw new AccessDeniedHttpException();
     }
 }
コード例 #4
0
ファイル: WikiService.php プロジェクト: terretta/gitki.php
 /**
  * @param User     $user
  * @param FilePath $relativeOldFilePath
  * @param FilePath $relativeNewFilePath
  * @param string   $commitMessage
  *
  * @throws FileExistsException
  * @throws \Exception
  */
 public function renameFile(User $user, FilePath $relativeOldFilePath, FilePath $relativeNewFilePath, $commitMessage)
 {
     if ($this->gitRepository->exists($relativeNewFilePath)) {
         throw new FileExistsException('File ' . $relativeNewFilePath->toRelativeFileString() . ' already exists');
     }
     if (empty($commitMessage)) {
         throw new \Exception('Commit message must not be empty');
     }
     $oldLockPath = $this->getLockPath($relativeOldFilePath);
     $this->assertHasLock($user, $oldLockPath);
     $this->createLock($user, $relativeNewFilePath);
     $this->gitRepository->moveAndCommit($this->getAuthor($user), $commitMessage, $relativeOldFilePath, $relativeNewFilePath);
     $this->removeLock($user, $relativeOldFilePath);
     $this->removeLock($user, $relativeNewFilePath);
     if (StringUtils::endsWith($relativeOldFilePath->getName(), '.md')) {
         $this->eventDispatcher->dispatch('ddr.gitki.wiki.markdown_document.deleted', new MarkdownDocumentDeletedEvent($relativeOldFilePath, $user->getRealName(), time(), $commitMessage));
     }
     if (StringUtils::endsWith($relativeNewFilePath->getName(), '.md')) {
         $content = $this->getContent($relativeNewFilePath);
         $parsedMarkdownDocument = $this->markdownService->parse($relativeNewFilePath, $content);
         $this->eventDispatcher->dispatch('ddr.gitki.wiki.markdown_document.saved', new MarkdownDocumentSavedEvent($relativeNewFilePath, $user->getEmail(), time(), $parsedMarkdownDocument, $commitMessage));
     }
 }