ComposerInstallersInstaller

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