protected function addRepo($username, $name) { $repo = $this->getRepository('Repo')->findOneByUsernameAndName($username, $name); if ($repo) { return $repo; } $github = new \phpGithubApi(); $github->setRequest(new Github\Request()); $githubRepo = new Github\Repo($github, new Output()); if (!($repo = $githubRepo->update(Repo::create($username . '/' . $name)))) { return false; } if (!($user = $this->getUserRepository()->findOneByName($username))) { $githubUser = new Github\User(new \phpGithubApi(), new Output()); if (!($user = $githubUser->import($username))) { return false; } } $user->addRepo($repo); $dm = $this->container->getDoctrine_Orm_DefaultEntityManagerService(); $dm->persist($repo); $dm->persist($user); $dm->flush(); return $repo; }
protected function addRepo($username, $name) { $repo = $this->getRepository('Repo')->findOneByUsernameAndName($username, $name); if ($repo) { return $repo; } $github = new \phpGithubApi(); $github->setRequest(new Github\Request()); $gitRepoManager = new Git\RepoManager($this->reposDir); $githubRepo = new Github\Repo($github, new Output(), $gitRepoManager); $repo = $githubRepo->update(Repo::create($username . '/' . $name)); if (!$repo) { return false; } $user = $this->getUserRepository()->findOneByName($username); if (!$user) { $githubUser = new Github\User(new \phpGithubApi(), new Output()); $user = $githubUser->import($username); if (!$user) { return false; } } $user->addRepo($repo); $this->dm->persist($repo); $this->dm->persist($user); $this->dm->flush(); return $repo; }