ComposerInstallersCakePHPInstaller

The Simple Calendar Composer Installers CakePHPInstaller class.

Defined (1)

The class is defined in the following location(s).

/vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php  
  1. class CakePHPInstaller extends BaseInstaller 
  2. protected $locations = array( 
  3. 'plugin' => 'Plugin/{$name}/',  
  4. ); 
  5.  
  6. /** 
  7. * Format package name to CamelCase 
  8. */ 
  9. public function inflectPackageVars($vars) 
  10. if ($this->matchesCakeVersion('>=', '3.0.0')) { 
  11. return $vars; 
  12.  
  13. $nameParts = explode('/', $vars['name']); 
  14. foreach ($nameParts as &$value) { 
  15. $value = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $value)); 
  16. $value = str_replace(array('-', '_'), ' ', $value); 
  17. $value = str_replace(' ', '', ucwords($value)); 
  18. $vars['name'] = implode('/', $nameParts); 
  19.  
  20. return $vars; 
  21.  
  22. /** 
  23. * Change the default plugin location when cakephp >= 3.0 
  24. */ 
  25. public function getLocations() 
  26. if ($this->matchesCakeVersion('>=', '3.0.0')) { 
  27. $this->locations['plugin'] = $this->composer->getConfig()->get('vendor-dir') . '/{$vendor}/{$name}/'; 
  28. return $this->locations; 
  29.  
  30. /** 
  31. * Check if CakePHP version matches against a version 
  32. * @param string $matcher 
  33. * @param string $version 
  34. * @return bool 
  35. */ 
  36. protected function matchesCakeVersion($matcher, $version) 
  37. if (class_exists('Composer\Semver\Constraint\MultiConstraint')) { 
  38. $multiClass = 'Composer\Semver\Constraint\MultiConstraint'; 
  39. $constraintClass = 'Composer\Semver\Constraint\Constraint'; 
  40. } else { 
  41. $multiClass = 'Composer\Package\LinkConstraint\MultiConstraint'; 
  42. $constraintClass = 'Composer\Package\LinkConstraint\VersionConstraint'; 
  43.  
  44. $repositoryManager = $this->composer->getRepositoryManager(); 
  45. if ($repositoryManager) { 
  46. $repos = $repositoryManager->getLocalRepository(); 
  47. if (!$repos) { 
  48. return false; 
  49. $cake3 = new $multiClass(array( 
  50. new $constraintClass($matcher, $version),  
  51. new $constraintClass('!=', '9999999-dev'),  
  52. )); 
  53. $pool = new Pool('dev'); 
  54. $pool->addRepository($repos); 
  55. $packages = $pool->whatProvides('cakephp/cakephp'); 
  56. foreach ($packages as $package) { 
  57. $installed = new $constraintClass('=', $package->getVersion()); 
  58. if ($cake3->matches($installed)) { 
  59. return true; 
  60. break; 
  61. return false;