ComposerInstallersInstaller

The Google Analytics by Yoast Composer Installers Installer class.

Defined (1)

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

/vendor/composer/installers/src/Composer/Installers/Installer.php  
  1. class Installer extends LibraryInstaller 
  2. /** 
  3. * Package types to installer class map 
  4. * @var array 
  5. */ 
  6. private $supportedTypes = array( 
  7. 'aimeos' => 'AimeosInstaller',  
  8. 'asgard' => 'AsgardInstaller',  
  9. 'agl' => 'AglInstaller',  
  10. 'annotatecms' => 'AnnotateCmsInstaller',  
  11. 'bitrix' => 'BitrixInstaller',  
  12. 'bonefish' => 'BonefishInstaller',  
  13. 'cakephp' => 'CakePHPInstaller',  
  14. 'chef' => 'ChefInstaller',  
  15. 'ccframework' => 'ClanCatsFrameworkInstaller',  
  16. 'codeigniter' => 'CodeIgniterInstaller',  
  17. 'concrete5' => 'Concrete5Installer',  
  18. 'craft' => 'CraftInstaller',  
  19. 'croogo' => 'CroogoInstaller',  
  20. 'dokuwiki' => 'DokuWikiInstaller',  
  21. 'dolibarr' => 'DolibarrInstaller',  
  22. 'drupal' => 'DrupalInstaller',  
  23. 'elgg' => 'ElggInstaller',  
  24. 'fuel' => 'FuelInstaller',  
  25. 'fuelphp' => 'FuelphpInstaller',  
  26. 'grav' => 'GravInstaller',  
  27. 'hurad' => 'HuradInstaller',  
  28. 'joomla' => 'JoomlaInstaller',  
  29. 'kirby' => 'KirbyInstaller',  
  30. 'kodicms' => 'KodiCMSInstaller',  
  31. 'kohana' => 'KohanaInstaller',  
  32. 'laravel' => 'LaravelInstaller',  
  33. 'lithium' => 'LithiumInstaller',  
  34. 'magento' => 'MagentoInstaller',  
  35. 'mako' => 'MakoInstaller',  
  36. 'mediawiki' => 'MediaWikiInstaller',  
  37. 'microweber' => 'MicroweberInstaller',  
  38. 'modulework' => 'MODULEWorkInstaller',  
  39. 'modxevo' => 'MODXEvoInstaller',  
  40. 'moodle' => 'MoodleInstaller',  
  41. 'october' => 'OctoberInstaller',  
  42. 'oxid' => 'OxidInstaller',  
  43. 'phpbb' => 'PhpBBInstaller',  
  44. 'pimcore' => 'PimcoreInstaller',  
  45. 'piwik' => 'PiwikInstaller',  
  46. 'ppi' => 'PPIInstaller',  
  47. 'puppet' => 'PuppetInstaller',  
  48. 'redaxo' => 'RedaxoInstaller',  
  49. 'roundcube' => 'RoundcubeInstaller',  
  50. 'shopware' => 'ShopwareInstaller',  
  51. 'silverstripe' => 'SilverStripeInstaller',  
  52. 'smf' => 'SMFInstaller',  
  53. 'symfony1' => 'Symfony1Installer',  
  54. 'thelia' => 'TheliaInstaller',  
  55. 'tusk' => 'TuskInstaller',  
  56. 'typo3-cms' => 'TYPO3CmsInstaller',  
  57. 'typo3-flow' => 'TYPO3FlowInstaller',  
  58. 'whmcs' => 'WHMCSInstaller',  
  59. 'wolfcms' => 'WolfCMSInstaller',  
  60. 'wordpress' => 'WordPressInstaller',  
  61. 'zend' => 'ZendInstaller',  
  62. 'zikula' => 'ZikulaInstaller',  
  63. 'prestashop' => 'PrestashopInstaller' 
  64. ); 
  65.  
  66. /** 
  67. * {@inheritDoc} 
  68. */ 
  69. public function getInstallPath(PackageInterface $package) 
  70. $type = $package->getType(); 
  71. $frameworkType = $this->findFrameworkType($type); 
  72.  
  73. if ($frameworkType === false) { 
  74. throw new \InvalidArgumentException( 
  75. 'Sorry the package type of this package is not yet supported.' 
  76. ); 
  77.  
  78. $class = 'Composer\\Installers\\' . $this->supportedTypes[$frameworkType]; 
  79. $installer = new $class($package, $this->composer); 
  80.  
  81. return $installer->getInstallPath($package, $frameworkType); 
  82.  
  83. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package) 
  84. if (!$repo->hasPackage($package)) { 
  85. throw new \InvalidArgumentException('Package is not installed: '.$package); 
  86.  
  87. $repo->removePackage($package); 
  88.  
  89. $installPath = $this->getInstallPath($package); 
  90. $this->io->write(sprintf('Deleting %s - %s', $installPath, $this->filesystem->removeDirectory($installPath) ? '<comment>deleted</comment>' : '<error>not deleted</error>')); 
  91.  
  92. /** 
  93. * {@inheritDoc} 
  94. */ 
  95. public function supports($packageType) 
  96. $frameworkType = $this->findFrameworkType($packageType); 
  97.  
  98. if ($frameworkType === false) { 
  99. return false; 
  100.  
  101. $locationPattern = $this->getLocationPattern($frameworkType); 
  102.  
  103. return preg_match('#' . $frameworkType . '-' . $locationPattern . '#', $packageType, $matches) === 1; 
  104.  
  105. /** 
  106. * Finds a supported framework type if it exists and returns it 
  107. * @param string $type 
  108. * @return string 
  109. */ 
  110. protected function findFrameworkType($type) 
  111. $frameworkType = false; 
  112.  
  113. krsort($this->supportedTypes); 
  114.  
  115. foreach ($this->supportedTypes as $key => $val) { 
  116. if ($key === substr($type, 0, strlen($key))) { 
  117. $frameworkType = substr($type, 0, strlen($key)); 
  118. break; 
  119.  
  120. return $frameworkType; 
  121.  
  122. /** 
  123. * Get the second part of the regular expression to check for support of a 
  124. * package type 
  125. * @param string $frameworkType 
  126. * @return string 
  127. */ 
  128. protected function getLocationPattern($frameworkType) 
  129. $pattern = false; 
  130. if (!empty($this->supportedTypes[$frameworkType])) { 
  131. $frameworkClass = 'Composer\\Installers\\' . $this->supportedTypes[$frameworkType]; 
  132. /** @var BaseInstaller $framework */ 
  133. $framework = new $frameworkClass(null, $this->composer); 
  134. $locations = array_keys($framework->getLocations()); 
  135. $pattern = $locations ? '(' . implode('|', $locations) . ')' : false; 
  136.  
  137. return $pattern ? : '(\w+)';