PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.2.65
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.2.65
1.2.74 1.2.73 1.2.72 1.2.71 1.2.70 1.2.69 1.2.68 1.2.67 1.2.66 1.2.65 1.2.64 1.2.63 trunk 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 All 174 releases
userswp / vendor / composer / installers / src / Composer / Installers / Installer.php

Installer.php in UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP 1.2.65, at vendor/composer/installers/src/Composer/Installers/Installer.php

299 lines 10.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Composer\Installers;
4
5 use Composer\Composer;
6 use Composer\Installer\BinaryInstaller;
7 use Composer\Installer\LibraryInstaller;
8 use Composer\IO\IOInterface;
9 use Composer\Package\PackageInterface;
10 use Composer\Repository\InstalledRepositoryInterface;
11 use Composer\Util\Filesystem;
12 use React\Promise\PromiseInterface;
13
14 class Installer extends LibraryInstaller
15 {
16
17 /**
18 * Package types to installer class map
19 *
20 * @var array
21 */
22 private $supportedTypes = array(
23 'aimeos' => 'AimeosInstaller',
24 'asgard' => 'AsgardInstaller',
25 'attogram' => 'AttogramInstaller',
26 'agl' => 'AglInstaller',
27 'annotatecms' => 'AnnotateCmsInstaller',
28 'bitrix' => 'BitrixInstaller',
29 'bonefish' => 'BonefishInstaller',
30 'cakephp' => 'CakePHPInstaller',
31 'chef' => 'ChefInstaller',
32 'civicrm' => 'CiviCrmInstaller',
33 'ccframework' => 'ClanCatsFrameworkInstaller',
34 'cockpit' => 'CockpitInstaller',
35 'codeigniter' => 'CodeIgniterInstaller',
36 'concrete5' => 'Concrete5Installer',
37 'craft' => 'CraftInstaller',
38 'croogo' => 'CroogoInstaller',
39 'dframe' => 'DframeInstaller',
40 'dokuwiki' => 'DokuWikiInstaller',
41 'dolibarr' => 'DolibarrInstaller',
42 'decibel' => 'DecibelInstaller',
43 'drupal' => 'DrupalInstaller',
44 'elgg' => 'ElggInstaller',
45 'eliasis' => 'EliasisInstaller',
46 'ee3' => 'ExpressionEngineInstaller',
47 'ee2' => 'ExpressionEngineInstaller',
48 'ezplatform' => 'EzPlatformInstaller',
49 'fuel' => 'FuelInstaller',
50 'fuelphp' => 'FuelphpInstaller',
51 'grav' => 'GravInstaller',
52 'hurad' => 'HuradInstaller',
53 'tastyigniter' => 'TastyIgniterInstaller',
54 'imagecms' => 'ImageCMSInstaller',
55 'itop' => 'ItopInstaller',
56 'joomla' => 'JoomlaInstaller',
57 'kanboard' => 'KanboardInstaller',
58 'kirby' => 'KirbyInstaller',
59 'known' => 'KnownInstaller',
60 'kodicms' => 'KodiCMSInstaller',
61 'kohana' => 'KohanaInstaller',
62 'lms' => 'LanManagementSystemInstaller',
63 'laravel' => 'LaravelInstaller',
64 'lavalite' => 'LavaLiteInstaller',
65 'lithium' => 'LithiumInstaller',
66 'magento' => 'MagentoInstaller',
67 'majima' => 'MajimaInstaller',
68 'mantisbt' => 'MantisBTInstaller',
69 'mako' => 'MakoInstaller',
70 'maya' => 'MayaInstaller',
71 'mautic' => 'MauticInstaller',
72 'mediawiki' => 'MediaWikiInstaller',
73 'miaoxing' => 'MiaoxingInstaller',
74 'microweber' => 'MicroweberInstaller',
75 'modulework' => 'MODULEWorkInstaller',
76 'modx' => 'ModxInstaller',
77 'modxevo' => 'MODXEvoInstaller',
78 'moodle' => 'MoodleInstaller',
79 'october' => 'OctoberInstaller',
80 'ontowiki' => 'OntoWikiInstaller',
81 'oxid' => 'OxidInstaller',
82 'osclass' => 'OsclassInstaller',
83 'pxcms' => 'PxcmsInstaller',
84 'phpbb' => 'PhpBBInstaller',
85 'pimcore' => 'PimcoreInstaller',
86 'piwik' => 'PiwikInstaller',
87 'plentymarkets'=> 'PlentymarketsInstaller',
88 'ppi' => 'PPIInstaller',
89 'puppet' => 'PuppetInstaller',
90 'radphp' => 'RadPHPInstaller',
91 'phifty' => 'PhiftyInstaller',
92 'porto' => 'PortoInstaller',
93 'processwire' => 'ProcessWireInstaller',
94 'quicksilver' => 'PantheonInstaller',
95 'redaxo' => 'RedaxoInstaller',
96 'redaxo5' => 'Redaxo5Installer',
97 'reindex' => 'ReIndexInstaller',
98 'roundcube' => 'RoundcubeInstaller',
99 'shopware' => 'ShopwareInstaller',
100 'sitedirect' => 'SiteDirectInstaller',
101 'silverstripe' => 'SilverStripeInstaller',
102 'smf' => 'SMFInstaller',
103 'starbug' => 'StarbugInstaller',
104 'sydes' => 'SyDESInstaller',
105 'sylius' => 'SyliusInstaller',
106 'symfony1' => 'Symfony1Installer',
107 'tao' => 'TaoInstaller',
108 'thelia' => 'TheliaInstaller',
109 'tusk' => 'TuskInstaller',
110 'typo3-cms' => 'TYPO3CmsInstaller',
111 'typo3-flow' => 'TYPO3FlowInstaller',
112 'userfrosting' => 'UserFrostingInstaller',
113 'vanilla' => 'VanillaInstaller',
114 'whmcs' => 'WHMCSInstaller',
115 'winter' => 'WinterInstaller',
116 'wolfcms' => 'WolfCMSInstaller',
117 'wordpress' => 'WordPressInstaller',
118 'yawik' => 'YawikInstaller',
119 'zend' => 'ZendInstaller',
120 'zikula' => 'ZikulaInstaller',
121 'prestashop' => 'PrestashopInstaller'
122 );
123
124 /**
125 * Installer constructor.
126 *
127 * Disables installers specified in main composer extra installer-disable
128 * list
129 *
130 * @param IOInterface $io
131 * @param Composer $composer
132 * @param string $type
133 * @param Filesystem|null $filesystem
134 * @param BinaryInstaller|null $binaryInstaller
135 */
136 public function __construct(
137 IOInterface $io,
138 Composer $composer,
139 $type = 'library',
140 Filesystem $filesystem = null,
141 BinaryInstaller $binaryInstaller = null
142 ) {
143 parent::__construct($io, $composer, $type, $filesystem,
144 $binaryInstaller);
145 $this->removeDisabledInstallers();
146 }
147
148 /**
149 * {@inheritDoc}
150 */
151 public function getInstallPath(PackageInterface $package)
152 {
153 $type = $package->getType();
154 $frameworkType = $this->findFrameworkType($type);
155
156 if ($frameworkType === false) {
157 throw new \InvalidArgumentException(
158 'Sorry the package type of this package is not yet supported.'
159 );
160 }
161
162 $class = 'Composer\\Installers\\' . $this->supportedTypes[$frameworkType];
163 $installer = new $class($package, $this->composer, $this->getIO());
164
165 return $installer->getInstallPath($package, $frameworkType);
166 }
167
168 public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
169 {
170 $installPath = $this->getPackageBasePath($package);
171 $io = $this->io;
172 $outputStatus = function () use ($io, $installPath) {
173 $io->write(sprintf('Deleting %s - %s', $installPath, !file_exists($installPath) ? '<comment>deleted</comment>' : '<error>not deleted</error>'));
174 };
175
176 $promise = parent::uninstall($repo, $package);
177
178 // Composer v2 might return a promise here
179 if ($promise instanceof PromiseInterface) {
180 return $promise->then($outputStatus);
181 }
182
183 // If not, execute the code right away as parent::uninstall executed synchronously (composer v1, or v2 without async)
184 $outputStatus();
185
186 return null;
187 }
188
189 /**
190 * {@inheritDoc}
191 */
192 public function supports($packageType)
193 {
194 $frameworkType = $this->findFrameworkType($packageType);
195
196 if ($frameworkType === false) {
197 return false;
198 }
199
200 $locationPattern = $this->getLocationPattern($frameworkType);
201
202 return preg_match('#' . $frameworkType . '-' . $locationPattern . '#', $packageType, $matches) === 1;
203 }
204
205 /**
206 * Finds a supported framework type if it exists and returns it
207 *
208 * @param string $type
209 * @return string|false
210 */
211 protected function findFrameworkType($type)
212 {
213 krsort($this->supportedTypes);
214
215 foreach ($this->supportedTypes as $key => $val) {
216 if ($key === substr($type, 0, strlen($key))) {
217 return substr($type, 0, strlen($key));
218 }
219 }
220
221 return false;
222 }
223
224 /**
225 * Get the second part of the regular expression to check for support of a
226 * package type
227 *
228 * @param string $frameworkType
229 * @return string
230 */
231 protected function getLocationPattern($frameworkType)
232 {
233 $pattern = false;
234 if (!empty($this->supportedTypes[$frameworkType])) {
235 $frameworkClass = 'Composer\\Installers\\' . $this->supportedTypes[$frameworkType];
236 /** @var BaseInstaller $framework */
237 $framework = new $frameworkClass(null, $this->composer, $this->getIO());
238 $locations = array_keys($framework->getLocations());
239 $pattern = $locations ? '(' . implode('|', $locations) . ')' : false;
240 }
241
242 return $pattern ? : '(\w+)';
243 }
244
245 /**
246 * Get I/O object
247 *
248 * @return IOInterface
249 */
250 private function getIO()
251 {
252 return $this->io;
253 }
254
255 /**
256 * Look for installers set to be disabled in composer's extra config and
257 * remove them from the list of supported installers.
258 *
259 * Globals:
260 * - true, "all", and "*" - disable all installers.
261 * - false - enable all installers (useful with
262 * wikimedia/composer-merge-plugin or similar)
263 *
264 * @return void
265 */
266 protected function removeDisabledInstallers()
267 {
268 $extra = $this->composer->getPackage()->getExtra();
269
270 if (!isset($extra['installer-disable']) || $extra['installer-disable'] === false) {
271 // No installers are disabled
272 return;
273 }
274
275 // Get installers to disable
276 $disable = $extra['installer-disable'];
277
278 // Ensure $disabled is an array
279 if (!is_array($disable)) {
280 $disable = array($disable);
281 }
282
283 // Check which installers should be disabled
284 $all = array(true, "all", "*");
285 $intersect = array_intersect($all, $disable);
286 if (!empty($intersect)) {
287 // Disable all installers
288 $this->supportedTypes = array();
289 } else {
290 // Disable specified installers
291 foreach ($disable as $key => $installer) {
292 if (is_string($installer) && key_exists($installer, $this->supportedTypes)) {
293 unset($this->supportedTypes[$installer]);
294 }
295 }
296 }
297 }
298 }
299