-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from packagist/package-subrepository-access
Packages: add support for setting the default subrepository access
- Loading branch information
Showing
6 changed files
with
234 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace PrivatePackagist\ApiClient\Payload; | ||
|
||
/** | ||
* @internal | ||
* @final | ||
*/ | ||
class ArtifactPackageConfig | ||
{ | ||
/** @var int[] */ | ||
private $artifactPackageFileIds; | ||
/** @var ?string */ | ||
private $defaultSubrepositoryAccess; | ||
|
||
/** | ||
* @param int[] $artifactPackageFileIds | ||
* @param ?string $defaultSubrepositoryAccess | ||
*/ | ||
public function __construct(array $artifactPackageFileIds, $defaultSubrepositoryAccess) | ||
{ | ||
$this->artifactPackageFileIds = $artifactPackageFileIds; | ||
$this->defaultSubrepositoryAccess = $defaultSubrepositoryAccess; | ||
} | ||
|
||
/** | ||
* @return array{repoType: string, artifactIds: int[], defaultSubrepositoryAccess?: string} | ||
*/ | ||
public function toParameters(): array | ||
{ | ||
$data = [ | ||
'repoType' => 'artifact', | ||
'artifactIds' => $this->artifactPackageFileIds, | ||
]; | ||
|
||
if ($this->defaultSubrepositoryAccess) { | ||
$data['defaultSubrepositoryAccess'] = $this->defaultSubrepositoryAccess; | ||
} | ||
|
||
return $data; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace PrivatePackagist\ApiClient\Payload; | ||
|
||
/** | ||
* @internal | ||
* @final | ||
*/ | ||
class CustomPackageConfig | ||
{ | ||
/** @var string */ | ||
private $customJson; | ||
/** @var ?int */ | ||
private $credentialId; | ||
/** @var ?string */ | ||
private $defaultSubrepositoryAccess; | ||
|
||
/** | ||
* @param string|array|object $customJson | ||
* @param ?int $credentialId | ||
* @param ?string $defaultSubrepositoryAccess | ||
*/ | ||
public function __construct($customJson, $credentialId, $defaultSubrepositoryAccess) | ||
{ | ||
if (is_array($customJson) || is_object($customJson)) { | ||
$customJson = json_encode($customJson); | ||
} | ||
|
||
$this->customJson = $customJson; | ||
$this->credentialId = $credentialId; | ||
$this->defaultSubrepositoryAccess = $defaultSubrepositoryAccess; | ||
} | ||
|
||
/** | ||
* @return array{repoType: string, repoConfig: string, credentials: ?int, defaultSubrepositoryAccess?: string} | ||
*/ | ||
public function toParameters(): array | ||
{ | ||
$data = [ | ||
'repoType' => 'package', | ||
'repoConfig' => $this->customJson, | ||
'credentials' => $this->credentialId, | ||
]; | ||
|
||
if ($this->defaultSubrepositoryAccess) { | ||
$data['defaultSubrepositoryAccess'] = $this->defaultSubrepositoryAccess; | ||
} | ||
|
||
return $data; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace PrivatePackagist\ApiClient\Payload; | ||
|
||
/** | ||
* @internal | ||
* @final | ||
*/ | ||
class VcsPackageConfig | ||
{ | ||
/** @var string */ | ||
private $url; | ||
/** @var ?int */ | ||
private $credentialId; | ||
/** @var string */ | ||
private $type; | ||
/** @var ?string */ | ||
private $defaultSubrepositoryAccess; | ||
|
||
/** | ||
* @param string $url | ||
* @param ?int $credentialId | ||
* @param string $type | ||
* @param ?string $defaultSubrepositoryAccess | ||
*/ | ||
public function __construct($url, $credentialId, $type, $defaultSubrepositoryAccess) | ||
{ | ||
$this->url = $url; | ||
$this->credentialId = $credentialId; | ||
$this->type = $type; | ||
$this->defaultSubrepositoryAccess = $defaultSubrepositoryAccess; | ||
} | ||
|
||
/** | ||
* @return array{repoType: string, repoUrl: string, credentials: ?int, defaultSubrepositoryAccess?: string} | ||
*/ | ||
public function toParameters(): array | ||
{ | ||
$data = [ | ||
'repoType' => $this->type, | ||
'repoUrl' => $this->url, | ||
'credentials' => $this->credentialId, | ||
]; | ||
|
||
if ($this->defaultSubrepositoryAccess) { | ||
$data['defaultSubrepositoryAccess'] = $this->defaultSubrepositoryAccess; | ||
} | ||
|
||
return $data; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters