/**
  * @param $searchString
  * @return MarkdownSearchResult[]
  */
 public function searchMarkdownDocuments($searchString)
 {
     $params = array('index' => $this->index, 'type' => self::MARKDOWN_DOCUMENT_TYPE, 'fields' => array('title'));
     $searchStringParts = explode(' ', $searchString);
     foreach ($searchStringParts as $searchStringPart) {
         $params['body']['query']['bool']['should'][]['wildcard']['content'] = $searchStringPart . '*';
     }
     $result = $this->client->search($params);
     $numHits = $result['hits']['total'];
     if ($numHits == 0) {
         return array();
     }
     $searchResults = array();
     foreach ($result['hits']['hits'] as $hit) {
         $searchResult = new MarkdownSearchResult();
         $searchResult->setPath(FilePath::parse($hit['_id']));
         $searchResult->setScore($hit['_score']);
         if (isset($hit['fields'])) {
             if (isset($hit['fields']['title'][0])) {
                 $searchResult->setTitle($hit['fields']['title'][0]);
             }
         }
         $searchResults[] = $searchResult;
     }
     return $searchResults;
 }
 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
 public function testAddAndCommit()
 {
     $gitRepository = $this->createGitRepository();
     $filePath = FilePath::parse('test.txt');
     $gitRepository->putContent($filePath, 'asdf');
     $gitRepository->addAndCommit('"Tester <*****@*****.**>"', 'Added test.txt', $filePath);
     $this->assertTrue($gitRepository->exists($filePath));
     $history = $gitRepository->getFileHistory($filePath);
     $this->assertCount(1, $history);
     /** @var CommitMetadata $firstEntry */
     $firstEntry = $history[0];
     $this->assertEquals('Added test.txt', $firstEntry->getMessage());
     $this->assertEquals('*****@*****.**', $firstEntry->getEMail());
     $this->assertEquals('Tester', $firstEntry->getCommitter());
 }
Пример #4
0
 public function moveAndCommit($author, $commitMessage, FilePath $oldPath, FilePath $newPath)
 {
     $workingCopy = $this->getWorkingCopy();
     $workingCopy->mv($oldPath->toRelativeFileString(), $newPath->toRelativeFileString());
     $this->commit($author, $commitMessage);
 }
Пример #5
0
 public function __construct($basePath, $currentDirectoryPath, $relativeFilePath)
 {
     parent::__construct($basePath . $currentDirectoryPath . $relativeFilePath);
     $this->absolutePath = FilePath::parse($currentDirectoryPath . $relativeFilePath);
     $this->relativePath = FilePath::parse($relativeFilePath);
 }
Пример #6
0
 /**
  * @param Request  $request
  * @param FilePath $path
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function deleteFileAction(Request $request, FilePath $path)
 {
     $this->assertRole('ROLE_COMMITTER');
     $user = $this->getUser();
     $commitMessage = 'Removing ' . $path->toAbsoluteUrlString();
     $this->getWikiService()->deleteFile($user, $path, $commitMessage);
     return $this->redirect($this->generateUrl('ddr_gitki_wiki_directory', array('path' => $path->getParentPath()->toAbsoluteUrlString())));
 }
Пример #7
0
 /**
  * @param FilePath $relativeFilePath
  *
  * @return FilePath
  */
 protected function getLockPath(FilePath $relativeFilePath)
 {
     $name = $relativeFilePath->getName();
     $relativeLockPath = $relativeFilePath->getParentPath()->appendFile($name . '.lock');
     return $relativeLockPath;
 }