class CakePHPInstaller
Hierarchy
- class \Composer\Installers\BaseInstaller
- class \Composer\Installers\CakePHPInstaller extends \Composer\Installers\BaseInstaller
Expanded class hierarchy of CakePHPInstaller
File
-
vendor/
composer/ installers/ src/ Composer/ Installers/ CakePHPInstaller.php, line 8
Namespace
Composer\InstallersView source
class CakePHPInstaller extends BaseInstaller {
/** @var array<string, string> */
protected $locations = array(
'plugin' => 'Plugin/{$name}/',
);
/**
* Format package name to CamelCase
*/
public function inflectPackageVars(array $vars) : array {
if ($this->matchesCakeVersion('>=', '3.0.0')) {
return $vars;
}
$nameParts = explode('/', $vars['name']);
foreach ($nameParts as &$value) {
$value = strtolower($this->pregReplace('/(?<=\\w)([A-Z])/', '_\\1', $value));
$value = str_replace(array(
'-',
'_',
), ' ', $value);
$value = str_replace(' ', '', ucwords($value));
}
$vars['name'] = implode('/', $nameParts);
return $vars;
}
/**
* Change the default plugin location when cakephp >= 3.0
*/
public function getLocations(string $frameworkType) : array {
if ($this->matchesCakeVersion('>=', '3.0.0')) {
$this->locations['plugin'] = $this->composer
->getConfig()
->get('vendor-dir') . '/{$vendor}/{$name}/';
}
return $this->locations;
}
/**
* Check if CakePHP version matches against a version
*
* @phpstan-param '='|'=='|'<'|'<='|'>'|'>='|'<>'|'!=' $matcher
*/
protected function matchesCakeVersion(string $matcher, string $version) : bool {
$repositoryManager = $this->composer
->getRepositoryManager();
/** @phpstan-ignore-next-line */
if (!$repositoryManager) {
return false;
}
$repos = $repositoryManager->getLocalRepository();
/** @phpstan-ignore-next-line */
if (!$repos) {
return false;
}
return $repos->findPackage('cakephp/cakephp', new Constraint($matcher, $version)) !== null;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
BaseInstaller::$composer | protected | property | @var Composer | ||
BaseInstaller::$io | protected | property | @var IOInterface | ||
BaseInstaller::$package | protected | property | @var PackageInterface | ||
BaseInstaller::getInstallPath | public | function | Return the install path based on package type. | 2 | |
BaseInstaller::mapCustomInstallPaths | protected | function | Search through a passed paths array for a custom install path. | ||
BaseInstaller::pregReplace | protected | function | |||
BaseInstaller::templatePath | protected | function | Replace vars in a path | 1 | |
BaseInstaller::__construct | public | function | Initializes base installer. | ||
CakePHPInstaller::$locations | protected | property | @var array<string, string> | Overrides BaseInstaller::$locations | |
CakePHPInstaller::getLocations | public | function | Change the default plugin location when cakephp >= 3.0 | Overrides BaseInstaller::getLocations | |
CakePHPInstaller::inflectPackageVars | public | function | Format package name to CamelCase | Overrides BaseInstaller::inflectPackageVars | |
CakePHPInstaller::matchesCakeVersion | protected | function | Check if CakePHP version matches against a version |