コード例 #1
0
 /**
  * @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;
 }
コード例 #2
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());
 }
コード例 #3
0
ファイル: File.php プロジェクト: terretta/gitki.php
 public function __construct($basePath, $currentDirectoryPath, $relativeFilePath)
 {
     parent::__construct($basePath . $currentDirectoryPath . $relativeFilePath);
     $this->absolutePath = FilePath::parse($currentDirectoryPath . $relativeFilePath);
     $this->relativePath = FilePath::parse($relativeFilePath);
 }
コード例 #4
0
ファイル: WikiController.php プロジェクト: terretta/gitki.php
 /**
  * @param Request  $request
  * @param FilePath $path
  *
  * @return Response
  * @throws ConflictHttpException
  */
 public function renameFileAction(Request $request, FilePath $path)
 {
     $this->assertRole('ROLE_COMMITTER');
     $user = $this->getUser();
     try {
         $this->getWikiService()->createLock($user, $path);
     } catch (PageLockedException $e) {
         throw new ConflictHttpException($e->getMessage());
     }
     $form = $this->createFormBuilder()->add('newpath', 'text', array('label' => 'New path', 'required' => true))->add('rename', 'submit')->getForm();
     $form->handleRequest($request);
     if ($form->isSubmitted()) {
         if ($form->isValid()) {
             $newPath = FilePath::parse($form->get('newpath')->getData());
             $this->getWikiService()->renameFile($user, $path, $newPath, 'Renaming ' . $path->toAbsoluteUrlString() . ' to ' . $newPath->toAbsoluteUrlString());
             return $this->redirect($this->generateUrl('ddr_gitki_wiki_directory', array('path' => $newPath->getParentPath()->toAbsoluteUrlString())));
         }
     } else {
         $form->setData(array('newpath' => $path->toAbsoluteUrlString()));
     }
     return $this->render('DdrGitkiBaseBundle:Wiki:file.rename.html.twig', array('form' => $form->createView(), 'path' => $path));
 }
コード例 #5
0
ファイル: WikiService.php プロジェクト: terretta/gitki.php
 /**
  * @return FilePath[]
  */
 public function findAllMarkdownFiles()
 {
     $finder = new Finder();
     $finder->in($this->gitRepository->getRepositoryPath()->toAbsoluteFileString());
     $finder->name('*.md');
     $filePaths = array();
     foreach ($finder->files() as $file) {
         /** @var SplFileInfo $file */
         $filePaths[] = FilePath::parse('/' . $file->getRelativePathname());
     }
     return $filePaths;
 }