woocommerce-multilingual
/
vendor
/
composer
/
installers
/
src
/
Composer
/
Installers
/
BaseInstaller.php
woocommerce-multilingual
/
vendor
/
composer
/
installers
/
src
/
Composer
/
Installers
Last commit date
AglInstaller.php
1 month ago
AimeosInstaller.php
5 years ago
AnnotateCmsInstaller.php
5 years ago
AsgardInstaller.php
1 month ago
AttogramInstaller.php
5 years ago
BaseInstaller.php
1 month ago
BitrixInstaller.php
1 month ago
BonefishInstaller.php
5 years ago
CakePHPInstaller.php
1 month ago
ChefInstaller.php
5 years ago
CiviCrmInstaller.php
5 years ago
ClanCatsFrameworkInstaller.php
5 years ago
CockpitInstaller.php
1 month ago
CodeIgniterInstaller.php
5 years ago
Concrete5Installer.php
5 years ago
CraftInstaller.php
1 month ago
CroogoInstaller.php
1 month ago
DecibelInstaller.php
1 month ago
DframeInstaller.php
5 years ago
DokuWikiInstaller.php
1 month ago
DolibarrInstaller.php
1 month ago
DrupalInstaller.php
5 years ago
ElggInstaller.php
5 years ago
EliasisInstaller.php
5 years ago
ExpressionEngineInstaller.php
5 years ago
EzPlatformInstaller.php
5 years ago
FuelInstaller.php
5 years ago
FuelphpInstaller.php
5 years ago
GravInstaller.php
1 month ago
HuradInstaller.php
1 month ago
ImageCMSInstaller.php
5 years ago
Installer.php
1 month ago
ItopInstaller.php
5 years ago
JoomlaInstaller.php
1 month ago
KanboardInstaller.php
1 month ago
KirbyInstaller.php
5 years ago
KnownInstaller.php
5 years ago
KodiCMSInstaller.php
5 years ago
KohanaInstaller.php
5 years ago
LanManagementSystemInstaller.php
1 month ago
LaravelInstaller.php
5 years ago
LavaLiteInstaller.php
5 years ago
LithiumInstaller.php
5 years ago
MODULEWorkInstaller.php
5 years ago
MODXEvoInstaller.php
1 month ago
MagentoInstaller.php
5 years ago
MajimaInstaller.php
1 month ago
MakoInstaller.php
5 years ago
MantisBTInstaller.php
1 month ago
MauticInstaller.php
1 month ago
MayaInstaller.php
1 month ago
MediaWikiInstaller.php
1 month ago
MiaoxingInstaller.php
4 years ago
MicroweberInstaller.php
1 month ago
ModxInstaller.php
1 month ago
MoodleInstaller.php
4 years ago
OctoberInstaller.php
1 month ago
OntoWikiInstaller.php
1 month ago
OsclassInstaller.php
5 years ago
OxidInstaller.php
1 month ago
PPIInstaller.php
5 years ago
PantheonInstaller.php
1 month ago
PhiftyInstaller.php
5 years ago
PhpBBInstaller.php
5 years ago
PimcoreInstaller.php
1 month ago
PiwikInstaller.php
1 month ago
PlentymarketsInstaller.php
1 month ago
Plugin.php
5 years ago
PortoInstaller.php
5 years ago
PrestashopInstaller.php
5 years ago
ProcessWireInstaller.php
1 month ago
PuppetInstaller.php
5 years ago
PxcmsInstaller.php
1 month ago
RadPHPInstaller.php
1 month ago
ReIndexInstaller.php
5 years ago
Redaxo5Installer.php
5 years ago
RedaxoInstaller.php
5 years ago
RoundcubeInstaller.php
1 month ago
SMFInstaller.php
5 years ago
ShopwareInstaller.php
1 month ago
SilverStripeInstaller.php
1 month ago
SiteDirectInstaller.php
5 years ago
StarbugInstaller.php
4 years ago
SyDESInstaller.php
1 month ago
SyliusInstaller.php
5 years ago
Symfony1Installer.php
1 month ago
TYPO3CmsInstaller.php
1 month ago
TYPO3FlowInstaller.php
1 month ago
TaoInstaller.php
1 month ago
TastyIgniterInstaller.php
1 month ago
TheliaInstaller.php
5 years ago
TuskInstaller.php
1 month ago
UserFrostingInstaller.php
5 years ago
VanillaInstaller.php
5 years ago
VgmcpInstaller.php
1 month ago
WHMCSInstaller.php
5 years ago
WinterInstaller.php
1 month ago
WolfCMSInstaller.php
5 years ago
WordPressInstaller.php
5 years ago
YawikInstaller.php
1 month ago
ZendInstaller.php
5 years ago
ZikulaInstaller.php
5 years ago
BaseInstaller.php
97 lines
| 1 | <?php |
| 2 | namespace Composer\Installers; |
| 3 | |
| 4 | use Composer\IO\IOInterface; |
| 5 | use Composer\Composer; |
| 6 | use Composer\Package\PackageInterface; |
| 7 | |
| 8 | abstract class BaseInstaller |
| 9 | { |
| 10 | protected $locations = array(); |
| 11 | protected $composer; |
| 12 | protected $package; |
| 13 | protected $io; |
| 14 | |
| 15 | public function __construct(PackageInterface $package = null, Composer $composer = null, IOInterface $io = null) |
| 16 | { |
| 17 | $this->composer = $composer; |
| 18 | $this->package = $package; |
| 19 | $this->io = $io; |
| 20 | } |
| 21 | |
| 22 | public function getInstallPath(PackageInterface $package, $frameworkType = '') |
| 23 | { |
| 24 | $type = $this->package->getType(); |
| 25 | |
| 26 | $prettyName = $this->package->getPrettyName(); |
| 27 | if (strpos($prettyName, '/') !== false) { |
| 28 | list($vendor, $name) = explode('/', $prettyName); |
| 29 | } else { |
| 30 | $vendor = ''; |
| 31 | $name = $prettyName; |
| 32 | } |
| 33 | |
| 34 | $availableVars = $this->inflectPackageVars(compact('name', 'vendor', 'type')); |
| 35 | |
| 36 | $extra = $package->getExtra(); |
| 37 | if (!empty($extra['installer-name'])) { |
| 38 | $availableVars['name'] = $extra['installer-name']; |
| 39 | } |
| 40 | |
| 41 | if ($this->composer->getPackage()) { |
| 42 | $extra = $this->composer->getPackage()->getExtra(); |
| 43 | if (!empty($extra['installer-paths'])) { |
| 44 | $customPath = $this->mapCustomInstallPaths($extra['installer-paths'], $prettyName, $type, $vendor); |
| 45 | if ($customPath !== false) { |
| 46 | return $this->templatePath($customPath, $availableVars); |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | $packageType = substr($type, strlen($frameworkType) + 1); |
| 52 | $locations = $this->getLocations(); |
| 53 | if (!isset($locations[$packageType])) { |
| 54 | throw new \InvalidArgumentException(sprintf('Package type "%s" is not supported', $type)); |
| 55 | } |
| 56 | |
| 57 | return $this->templatePath($locations[$packageType], $availableVars); |
| 58 | } |
| 59 | |
| 60 | public function inflectPackageVars($vars) |
| 61 | { |
| 62 | return $vars; |
| 63 | } |
| 64 | |
| 65 | public function getLocations() |
| 66 | { |
| 67 | return $this->locations; |
| 68 | } |
| 69 | |
| 70 | protected function templatePath($path, array $vars = array()) |
| 71 | { |
| 72 | if (strpos($path, '{') !== false) { |
| 73 | extract($vars); |
| 74 | preg_match_all('@\{\$([A-Za-z0-9_]*)\}@i', $path, $matches); |
| 75 | if (!empty($matches[1])) { |
| 76 | foreach ($matches[1] as $var) { |
| 77 | $path = str_replace('{$' . $var . '}', $$var, $path); |
| 78 | } |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | return $path; |
| 83 | } |
| 84 | |
| 85 | protected function mapCustomInstallPaths(array $paths, $name, $type, $vendor = NULL) |
| 86 | { |
| 87 | foreach ($paths as $path => $names) { |
| 88 | $names = (array) $names; |
| 89 | if (in_array($name, $names) || in_array('type:' . $type, $names) || in_array('vendor:' . $vendor, $names)) { |
| 90 | return $path; |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | return false; |
| 95 | } |
| 96 | } |
| 97 |