Drop RepositoryOAuth2 interface in favor of a method_exists() guard

Matches the existing dynamic style already used in Factory::fromProvider()
for setEndpoint() -- less code than a formal interface just to gate one
optional capability on one call site.
This commit is contained in:
harsh mahajan committed 2026-07-21 13:07:25 +05:30
1 parent e47a2b54dd
commit 6a63b7ade2
5 files changed
+4 -22

No files matched your search

+1 -2
View File
@@ -3,9 +3,8 @@
namespace Appwrite\Auth\OAuth2;
use Appwrite\Auth\OAuth2;
use Appwrite\Vcs\RepositoryOAuth2;
class Gitea extends OAuth2 implements RepositoryOAuth2
class Gitea extends OAuth2
{
protected string $endpoint = '';
+1 -2
View File
@@ -3,10 +3,9 @@
namespace Appwrite\Auth\OAuth2;
use Appwrite\Auth\OAuth2;
use Appwrite\Vcs\RepositoryOAuth2;
use Utopia\Fetch\Client as FetchClient;
class Github extends OAuth2 implements RepositoryOAuth2
class Github extends OAuth2
{
/**
* @var array
+1 -2
View File
@@ -3,7 +3,6 @@
namespace Appwrite\Auth\OAuth2;
use Appwrite\Auth\OAuth2;
use Appwrite\Vcs\RepositoryOAuth2;
// Reference Material
// https://docs.gitlab.com/ee/api/oauth2.html
@@ -15,7 +14,7 @@ use Appwrite\Vcs\RepositoryOAuth2;
* only supports official gitlab.com, but still encodes to that same JSON
* shape so getAppSecret()/getEndpoint() stay correct for both consumers.
*/
class Gitlab extends OAuth2 implements RepositoryOAuth2
class Gitlab extends OAuth2
{
/**
* @var array
@@ -10,7 +10,6 @@ use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Utopia\Response;
use Appwrite\Vcs\Factory as VcsFactory;
use Appwrite\Vcs\InstallationTokens;
use Appwrite\Vcs\RepositoryOAuth2;
use Utopia\Database\Database;
use Utopia\Database\Document;
use Utopia\Database\Query;
@@ -81,7 +80,7 @@ class Create extends Action
if ($installation->getAttribute('personal', false) === true) {
$oauth2 = $vcsFactory->oauth2FromProvider($provider);
if (!$oauth2 instanceof RepositoryOAuth2) {
if (!\method_exists($oauth2, 'createRepository')) {
throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'VCS provider does not support repository creation: ' . $provider);
}
-14
View File
@@ -1,14 +0,0 @@
<?php
namespace Appwrite\Vcs;
/**
* Implemented by OAuth2 providers that can create a repository on behalf of
* a personal VCS installation. Narrow on purpose -- it's the only capability
* call sites need to check for beyond the base OAuth2 contract; construction
* from environment variables is the Factory's job, not the provider's.
*/
interface RepositoryOAuth2
{
public function createRepository(string $accessToken, string $repositoryName, bool $private): array;
}