ComposerInstallersCakePHPInstaller

The WordPress Core 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. $repositoryManager = $this->composer->getRepositoryManager(); 
  38. if ($repositoryManager) { 
  39. $repos = $repositoryManager->getLocalRepository(); 
  40. if (!$repos) { 
  41. return false; 
  42. $cake3 = new MultiConstraint(array( 
  43. new VersionConstraint($matcher, $version),  
  44. new VersionConstraint('!=', '9999999-dev'),  
  45. )); 
  46. $pool = new Pool('dev'); 
  47. $pool->addRepository($repos); 
  48. $packages = $pool->whatProvides('cakephp/cakephp'); 
  49. foreach ($packages as $package) { 
  50. $installed = new VersionConstraint('=', $package->getVersion()); 
  51. if ($cake3->matches($installed)) { 
  52. return true; 
  53. break; 
  54. return false;