Ejemplo n.º 1
0
 protected function getACLOrCreateIt(User $user, Repository $repository)
 {
     if (($repoACL = $this->getContainer()->get("doctrine")->getManager()->getRepository("AppBundle:RepositoryACL")->findOneBy(["user" => $user, "repository" => $repository])) == null) {
         $repoACL = new RepositoryACL();
         $repoACL->setUser($user);
         $repoACL->setRepository($repository);
     }
     return $repoACL;
 }
Ejemplo n.º 2
0
 /**
  * Retrieve or create the repository acl
  *
  * @param User $user
  * @param Repository $repository
  * @return RepositoryACL
  */
 protected function retrieveOrCreateRepositoryACL(User $user, Repository $repository)
 {
     $repositoryACL = $this->entityManager->getRepository("AppBundle:RepositoryACL")->findOneBy(["user" => $user, "repository" => $repository]);
     if ($repositoryACL == null) {
         $repositoryACL = new RepositoryACL();
         $repositoryACL->setUser($user);
         $repositoryACL->setRepository($repository);
     }
     return $repositoryACL;
 }
Ejemplo n.º 3
0
 /**
  * @Security("has_role('ROLE_USER')")
  * @Template
  */
 public function viewAction($login, $name)
 {
     // Retrieving the repo owner
     if (($owner = $this->getDoctrine()->getRepository("AppBundle:User")->findOneByLogin($login)) === null) {
         throw new NotFoundHttpException();
     }
     // Retrieving the repo
     if (($repository = $this->getDoctrine()->getRepository("AppBundle:Repository")->findOneBy(["owner" => $owner, "name" => $name])) === null) {
         throw new NotFoundHttpException();
     }
     // Updating the repository
     $this->get("app.service.blih_updater")->updateRepository($repository);
     $this->getDoctrine()->getManager()->refresh($repository);
     // Checking if the user cna view this repo
     if (!$repository->canView($this->getUser())) {
         throw new AccessDeniedHttpException();
     }
     $repositoryACL = new RepositoryACL();
     $repositoryACL->setRepository($repository);
     $repositoryACLForm = $this->createForm("repository_acl", $repositoryACL);
     return ["owner" => $owner, "repository" => $repository, "repositoryACLForm" => $repositoryACLForm->createView()];
 }