ComposerInstallersInstaller

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