class PerforceDriver
@author Matt Whittom <Matt.Whittom@veteransunited.com>
Hierarchy
- class \Composer\Repository\Vcs\VcsDriver implements \Composer\Repository\Vcs\VcsDriverInterface
- class \Composer\Repository\Vcs\PerforceDriver extends \Composer\Repository\Vcs\VcsDriver
Expanded class hierarchy of PerforceDriver
File
-
vendor/
composer/ composer/ src/ Composer/ Repository/ Vcs/ PerforceDriver.php, line 26
Namespace
Composer\Repository\VcsView source
class PerforceDriver extends VcsDriver {
/** @var string */
protected $depot;
/** @var string */
protected $branch;
/** @var ?Perforce */
protected $perforce = null;
/**
* @inheritDoc
*/
public function initialize() : void {
$this->depot = $this->repoConfig['depot'];
$this->branch = '';
if (!empty($this->repoConfig['branch'])) {
$this->branch = $this->repoConfig['branch'];
}
$this->initPerforce($this->repoConfig);
$this->perforce
->p4Login();
$this->perforce
->checkStream();
$this->perforce
->writeP4ClientSpec();
$this->perforce
->connectClient();
}
/**
* @param array<string, mixed> $repoConfig
*/
private function initPerforce(array $repoConfig) : void {
if (!empty($this->perforce)) {
return;
}
if (!Cache::isUsable($this->config
->get('cache-vcs-dir'))) {
throw new \RuntimeException('PerforceDriver requires a usable cache directory, and it looks like you set it to be disabled');
}
$repoDir = $this->config
->get('cache-vcs-dir') . '/' . $this->depot;
$this->perforce = Perforce::create($repoConfig, $this->getUrl(), $repoDir, $this->process, $this->io);
}
/**
* @inheritDoc
*/
public function getFileContent(string $file, string $identifier) : ?string {
return $this->perforce
->getFileContent($file, $identifier);
}
/**
* @inheritDoc
*/
public function getChangeDate(string $identifier) : ?\DateTimeImmutable {
return null;
}
/**
* @inheritDoc
*/
public function getRootIdentifier() : string {
return $this->branch;
}
/**
* @inheritDoc
*/
public function getBranches() : array {
return $this->perforce
->getBranches();
}
/**
* @inheritDoc
*/
public function getTags() : array {
return $this->perforce
->getTags();
}
/**
* @inheritDoc
*/
public function getDist(string $identifier) : ?array {
return null;
}
/**
* @inheritDoc
*/
public function getSource(string $identifier) : array {
return [
'type' => 'perforce',
'url' => $this->repoConfig['url'],
'reference' => $identifier,
'p4user' => $this->perforce
->getUser(),
];
}
/**
* @inheritDoc
*/
public function getUrl() : string {
return $this->url;
}
/**
* @inheritDoc
*/
public function hasComposerFile(string $identifier) : bool {
$composerInfo = $this->perforce
->getComposerInformation('//' . $this->depot . '/' . $identifier);
return !empty($composerInfo);
}
/**
* @inheritDoc
*/
public function getContents(string $url) : Response {
throw new \BadMethodCallException('Not implemented/used in PerforceDriver');
}
/**
* @inheritDoc
*/
public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false) : bool {
if ($deep || Preg::isMatch('#\\b(perforce|p4)\\b#i', $url)) {
return Perforce::checkServerExists($url, new ProcessExecutor($io));
}
return false;
}
/**
* @inheritDoc
*/
public function cleanup() : void {
$this->perforce
->cleanupClientSpec();
$this->perforce = null;
}
public function getDepot() : string {
return $this->depot;
}
public function getBranch() : string {
return $this->branch;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
PerforceDriver::$branch | protected | property | @var string | ||
PerforceDriver::$depot | protected | property | @var string | ||
PerforceDriver::$perforce | protected | property | @var ?Perforce | ||
PerforceDriver::cleanup | public | function | @inheritDoc | Overrides VcsDriver::cleanup | |
PerforceDriver::getBranch | public | function | |||
PerforceDriver::getBranches | public | function | @inheritDoc | Overrides VcsDriverInterface::getBranches | |
PerforceDriver::getChangeDate | public | function | @inheritDoc | Overrides VcsDriverInterface::getChangeDate | |
PerforceDriver::getContents | public | function | @inheritDoc | Overrides VcsDriver::getContents | |
PerforceDriver::getDepot | public | function | |||
PerforceDriver::getDist | public | function | @inheritDoc | Overrides VcsDriverInterface::getDist | |
PerforceDriver::getFileContent | public | function | @inheritDoc | Overrides VcsDriverInterface::getFileContent | |
PerforceDriver::getRootIdentifier | public | function | @inheritDoc | Overrides VcsDriverInterface::getRootIdentifier | |
PerforceDriver::getSource | public | function | @inheritDoc | Overrides VcsDriverInterface::getSource | |
PerforceDriver::getTags | public | function | @inheritDoc | Overrides VcsDriverInterface::getTags | |
PerforceDriver::getUrl | public | function | @inheritDoc | Overrides VcsDriverInterface::getUrl | |
PerforceDriver::hasComposerFile | public | function | @inheritDoc | Overrides VcsDriver::hasComposerFile | |
PerforceDriver::initialize | public | function | @inheritDoc | Overrides VcsDriverInterface::initialize | |
PerforceDriver::initPerforce | private | function | |||
PerforceDriver::supports | public static | function | @inheritDoc | Overrides VcsDriverInterface::supports | |
VcsDriver::$cache | protected | property | @var ?Cache | ||
VcsDriver::$config | protected | property | @var Config | ||
VcsDriver::$httpDownloader | protected | property | @var HttpDownloader | ||
VcsDriver::$infoCache | protected | property | @var array<int|string, mixed> | ||
VcsDriver::$io | protected | property | @var IOInterface | ||
VcsDriver::$originUrl | protected | property | @var string | ||
VcsDriver::$process | protected | property | @var ProcessExecutor | ||
VcsDriver::$repoConfig | protected | property | @var array<string, mixed> | ||
VcsDriver::$url | protected | property | @var string | ||
VcsDriver::getBaseComposerInformation | protected | function | |||
VcsDriver::getComposerInformation | public | function | @inheritDoc | Overrides VcsDriverInterface::getComposerInformation | 4 |
VcsDriver::getScheme | protected | function | Get the https or http protocol depending on SSL support. | ||
VcsDriver::shouldCache | protected | function | Returns whether or not the given $identifier should be cached or not. | 1 | |
VcsDriver::__construct | final public | function | Constructor. |