Mercurial > hg > isophonics-drupal-site
comparison vendor/composer/installers/src/Composer/Installers/Installer.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | 7a779792577d |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 namespace Composer\Installers; | |
3 | |
4 use Composer\IO\IOInterface; | |
5 use Composer\Installer\LibraryInstaller; | |
6 use Composer\Package\PackageInterface; | |
7 use Composer\Repository\InstalledRepositoryInterface; | |
8 | |
9 class Installer extends LibraryInstaller | |
10 { | |
11 /** | |
12 * Package types to installer class map | |
13 * | |
14 * @var array | |
15 */ | |
16 private $supportedTypes = array( | |
17 'aimeos' => 'AimeosInstaller', | |
18 'asgard' => 'AsgardInstaller', | |
19 'attogram' => 'AttogramInstaller', | |
20 'agl' => 'AglInstaller', | |
21 'annotatecms' => 'AnnotateCmsInstaller', | |
22 'bitrix' => 'BitrixInstaller', | |
23 'bonefish' => 'BonefishInstaller', | |
24 'cakephp' => 'CakePHPInstaller', | |
25 'chef' => 'ChefInstaller', | |
26 'ccframework' => 'ClanCatsFrameworkInstaller', | |
27 'cockpit' => 'CockpitInstaller', | |
28 'codeigniter' => 'CodeIgniterInstaller', | |
29 'concrete5' => 'Concrete5Installer', | |
30 'craft' => 'CraftInstaller', | |
31 'croogo' => 'CroogoInstaller', | |
32 'dokuwiki' => 'DokuWikiInstaller', | |
33 'dolibarr' => 'DolibarrInstaller', | |
34 'decibel' => 'DecibelInstaller', | |
35 'drupal' => 'DrupalInstaller', | |
36 'elgg' => 'ElggInstaller', | |
37 'eliasis' => 'EliasisInstaller', | |
38 'ee3' => 'ExpressionEngineInstaller', | |
39 'ee2' => 'ExpressionEngineInstaller', | |
40 'ezplatform' => 'EzPlatformInstaller', | |
41 'fuel' => 'FuelInstaller', | |
42 'fuelphp' => 'FuelphpInstaller', | |
43 'grav' => 'GravInstaller', | |
44 'hurad' => 'HuradInstaller', | |
45 'imagecms' => 'ImageCMSInstaller', | |
46 'itop' => 'ItopInstaller', | |
47 'joomla' => 'JoomlaInstaller', | |
48 'kanboard' => 'KanboardInstaller', | |
49 'kirby' => 'KirbyInstaller', | |
50 'kodicms' => 'KodiCMSInstaller', | |
51 'kohana' => 'KohanaInstaller', | |
52 'lms' => 'LanManagementSystemInstaller', | |
53 'laravel' => 'LaravelInstaller', | |
54 'lavalite' => 'LavaLiteInstaller', | |
55 'lithium' => 'LithiumInstaller', | |
56 'magento' => 'MagentoInstaller', | |
57 'mako' => 'MakoInstaller', | |
58 'maya' => 'MayaInstaller', | |
59 'mautic' => 'MauticInstaller', | |
60 'mediawiki' => 'MediaWikiInstaller', | |
61 'microweber' => 'MicroweberInstaller', | |
62 'modulework' => 'MODULEWorkInstaller', | |
63 'modxevo' => 'MODXEvoInstaller', | |
64 'moodle' => 'MoodleInstaller', | |
65 'october' => 'OctoberInstaller', | |
66 'ontowiki' => 'OntoWikiInstaller', | |
67 'oxid' => 'OxidInstaller', | |
68 'osclass' => 'OsclassInstaller', | |
69 'phpbb' => 'PhpBBInstaller', | |
70 'pimcore' => 'PimcoreInstaller', | |
71 'piwik' => 'PiwikInstaller', | |
72 'plentymarkets'=> 'PlentymarketsInstaller', | |
73 'ppi' => 'PPIInstaller', | |
74 'puppet' => 'PuppetInstaller', | |
75 'radphp' => 'RadPHPInstaller', | |
76 'phifty' => 'PhiftyInstaller', | |
77 'porto' => 'PortoInstaller', | |
78 'redaxo' => 'RedaxoInstaller', | |
79 'reindex' => 'ReIndexInstaller', | |
80 'roundcube' => 'RoundcubeInstaller', | |
81 'shopware' => 'ShopwareInstaller', | |
82 'silverstripe' => 'SilverStripeInstaller', | |
83 'smf' => 'SMFInstaller', | |
84 'sydes' => 'SyDESInstaller', | |
85 'symfony1' => 'Symfony1Installer', | |
86 'thelia' => 'TheliaInstaller', | |
87 'tusk' => 'TuskInstaller', | |
88 'typo3-cms' => 'TYPO3CmsInstaller', | |
89 'typo3-flow' => 'TYPO3FlowInstaller', | |
90 'userfrosting' => 'UserFrostingInstaller', | |
91 'vanilla' => 'VanillaInstaller', | |
92 'whmcs' => 'WHMCSInstaller', | |
93 'wolfcms' => 'WolfCMSInstaller', | |
94 'wordpress' => 'WordPressInstaller', | |
95 'yawik' => 'YawikInstaller', | |
96 'zend' => 'ZendInstaller', | |
97 'zikula' => 'ZikulaInstaller', | |
98 'prestashop' => 'PrestashopInstaller' | |
99 ); | |
100 | |
101 /** | |
102 * {@inheritDoc} | |
103 */ | |
104 public function getInstallPath(PackageInterface $package) | |
105 { | |
106 $type = $package->getType(); | |
107 $frameworkType = $this->findFrameworkType($type); | |
108 | |
109 if ($frameworkType === false) { | |
110 throw new \InvalidArgumentException( | |
111 'Sorry the package type of this package is not yet supported.' | |
112 ); | |
113 } | |
114 | |
115 $class = 'Composer\\Installers\\' . $this->supportedTypes[$frameworkType]; | |
116 $installer = new $class($package, $this->composer, $this->getIO()); | |
117 | |
118 return $installer->getInstallPath($package, $frameworkType); | |
119 } | |
120 | |
121 public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package) | |
122 { | |
123 if (!$repo->hasPackage($package)) { | |
124 throw new \InvalidArgumentException('Package is not installed: '.$package); | |
125 } | |
126 | |
127 $repo->removePackage($package); | |
128 | |
129 $installPath = $this->getInstallPath($package); | |
130 $this->io->write(sprintf('Deleting %s - %s', $installPath, $this->filesystem->removeDirectory($installPath) ? '<comment>deleted</comment>' : '<error>not deleted</error>')); | |
131 } | |
132 | |
133 /** | |
134 * {@inheritDoc} | |
135 */ | |
136 public function supports($packageType) | |
137 { | |
138 $frameworkType = $this->findFrameworkType($packageType); | |
139 | |
140 if ($frameworkType === false) { | |
141 return false; | |
142 } | |
143 | |
144 $locationPattern = $this->getLocationPattern($frameworkType); | |
145 | |
146 return preg_match('#' . $frameworkType . '-' . $locationPattern . '#', $packageType, $matches) === 1; | |
147 } | |
148 | |
149 /** | |
150 * Finds a supported framework type if it exists and returns it | |
151 * | |
152 * @param string $type | |
153 * @return string | |
154 */ | |
155 protected function findFrameworkType($type) | |
156 { | |
157 $frameworkType = false; | |
158 | |
159 krsort($this->supportedTypes); | |
160 | |
161 foreach ($this->supportedTypes as $key => $val) { | |
162 if ($key === substr($type, 0, strlen($key))) { | |
163 $frameworkType = substr($type, 0, strlen($key)); | |
164 break; | |
165 } | |
166 } | |
167 | |
168 return $frameworkType; | |
169 } | |
170 | |
171 /** | |
172 * Get the second part of the regular expression to check for support of a | |
173 * package type | |
174 * | |
175 * @param string $frameworkType | |
176 * @return string | |
177 */ | |
178 protected function getLocationPattern($frameworkType) | |
179 { | |
180 $pattern = false; | |
181 if (!empty($this->supportedTypes[$frameworkType])) { | |
182 $frameworkClass = 'Composer\\Installers\\' . $this->supportedTypes[$frameworkType]; | |
183 /** @var BaseInstaller $framework */ | |
184 $framework = new $frameworkClass(null, $this->composer, $this->getIO()); | |
185 $locations = array_keys($framework->getLocations()); | |
186 $pattern = $locations ? '(' . implode('|', $locations) . ')' : false; | |
187 } | |
188 | |
189 return $pattern ? : '(\w+)'; | |
190 } | |
191 | |
192 /** | |
193 * Get I/O object | |
194 * | |
195 * @return IOInterface | |
196 */ | |
197 private function getIO() | |
198 { | |
199 return $this->io; | |
200 } | |
201 } |