Allow browsing public snips
Fixed big with branch name not existing if nothing committed
This commit is contained in:
@ -28,6 +28,16 @@ class SnipController extends AbstractController
|
||||
{
|
||||
return $this->render('snip/index.html.twig', [
|
||||
'snips' => $this->repository->findByUser($this->getUser()),
|
||||
'title' => 'My Snips'
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/public', name: '_public')]
|
||||
public function public(): Response
|
||||
{
|
||||
return $this->render('snip/index.html.twig', [
|
||||
'snips' => $this->repository->findPublic(),
|
||||
'title' => 'Public Snips'
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -49,4 +49,14 @@ class SnipRepository extends ServiceEntityRepository
|
||||
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
|
||||
public function findPublic(): array
|
||||
{
|
||||
$qb = $this->createQueryBuilder('s');
|
||||
$qb->where('s.public = :public')
|
||||
->setParameter('public', true)
|
||||
->orderBy('s.createdAt', 'DESC');
|
||||
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,9 @@ class SnipServiceFactory
|
||||
$repoPath = sprintf('%s/%s', $this->snipBasePath, $snip->getId());
|
||||
if (!is_dir($repoPath)) {
|
||||
$repo = $git->init($repoPath);
|
||||
touch(sprintf('%s/.gitignore', $repoPath));
|
||||
$repo->addFile('.gitignore');
|
||||
$repo->commit('Initial commit');
|
||||
} else {
|
||||
$repo = $git->open($repoPath);
|
||||
}
|
||||
|
Reference in New Issue
Block a user