├── .github ├── dependabot.yml └── workflows │ ├── continuous-integration.yml │ ├── lint.yml │ └── phpstan.yml ├── LICENSE ├── composer.json └── src ├── Composer └── Installers │ ├── AglInstaller.php │ ├── AkauntingInstaller.php │ ├── AnnotateCmsInstaller.php │ ├── AsgardInstaller.php │ ├── AttogramInstaller.php │ ├── BaseInstaller.php │ ├── BitrixInstaller.php │ ├── BonefishInstaller.php │ ├── BotbleInstaller.php │ ├── CakePHPInstaller.php │ ├── ChefInstaller.php │ ├── CiviCrmInstaller.php │ ├── ClanCatsFrameworkInstaller.php │ ├── CockpitInstaller.php │ ├── CodeIgniterInstaller.php │ ├── Concrete5Installer.php │ ├── ConcreteCMSInstaller.php │ ├── CroogoInstaller.php │ ├── DecibelInstaller.php │ ├── DframeInstaller.php │ ├── DokuWikiInstaller.php │ ├── DolibarrInstaller.php │ ├── DrupalInstaller.php │ ├── ElggInstaller.php │ ├── EliasisInstaller.php │ ├── ExpressionEngineInstaller.php │ ├── EzPlatformInstaller.php │ ├── ForkCMSInstaller.php │ ├── FuelInstaller.php │ ├── FuelphpInstaller.php │ ├── GravInstaller.php │ ├── HuradInstaller.php │ ├── ImageCMSInstaller.php │ ├── Installer.php │ ├── ItopInstaller.php │ ├── KanboardInstaller.php │ ├── KnownInstaller.php │ ├── KodiCMSInstaller.php │ ├── KohanaInstaller.php │ ├── LanManagementSystemInstaller.php │ ├── LaravelInstaller.php │ ├── LavaLiteInstaller.php │ ├── LithiumInstaller.php │ ├── MODULEWorkInstaller.php │ ├── MODXEvoInstaller.php │ ├── MagentoInstaller.php │ ├── MajimaInstaller.php │ ├── MakoInstaller.php │ ├── MantisBTInstaller.php │ ├── MatomoInstaller.php │ ├── MauticInstaller.php │ ├── MayaInstaller.php │ ├── MediaWikiInstaller.php │ ├── MiaoxingInstaller.php │ ├── MicroweberInstaller.php │ ├── ModxInstaller.php │ ├── MoodleInstaller.php │ ├── OctoberInstaller.php │ ├── OntoWikiInstaller.php │ ├── OsclassInstaller.php │ ├── OxidInstaller.php │ ├── PPIInstaller.php │ ├── PantheonInstaller.php │ ├── PhiftyInstaller.php │ ├── PhpBBInstaller.php │ ├── PiwikInstaller.php │ ├── PlentymarketsInstaller.php │ ├── Plugin.php │ ├── PortoInstaller.php │ ├── PrestashopInstaller.php │ ├── ProcessWireInstaller.php │ ├── PuppetInstaller.php │ ├── PxcmsInstaller.php │ ├── RadPHPInstaller.php │ ├── ReIndexInstaller.php │ ├── Redaxo5Installer.php │ ├── RedaxoInstaller.php │ ├── RoundcubeInstaller.php │ ├── SMFInstaller.php │ ├── ShopwareInstaller.php │ ├── SilverStripeInstaller.php │ ├── SiteDirectInstaller.php │ ├── StarbugInstaller.php │ ├── SyDESInstaller.php │ ├── SyliusInstaller.php │ ├── TaoInstaller.php │ ├── TastyIgniterInstaller.php │ ├── TheliaInstaller.php │ ├── TuskInstaller.php │ ├── UserFrostingInstaller.php │ ├── VanillaInstaller.php │ ├── VgmcpInstaller.php │ ├── WHMCSInstaller.php │ ├── WinterInstaller.php │ ├── WolfCMSInstaller.php │ ├── WordPressInstaller.php │ ├── YawikInstaller.php │ ├── ZendInstaller.php │ └── ZikulaInstaller.php └── bootstrap.php /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | updates: 4 | - package-ecosystem: "github-actions" 5 | directory: "/" 6 | schedule: 7 | interval: "monthly" 8 | -------------------------------------------------------------------------------- /.github/workflows/continuous-integration.yml: -------------------------------------------------------------------------------- 1 | name: "Continuous Integration" 2 | 3 | on: 4 | - push 5 | - pull_request 6 | 7 | permissions: 8 | contents: read 9 | 10 | jobs: 11 | tests: 12 | name: "CI" 13 | 14 | runs-on: ${{ matrix.os }} 15 | continue-on-error: ${{ matrix.experimental }} 16 | 17 | strategy: 18 | matrix: 19 | php-version: 20 | - "7.2" 21 | - "7.3" 22 | - "7.4" 23 | - "8.0" 24 | - "8.1" 25 | - "8.2" 26 | - "8.3" 27 | - "8.4" 28 | dependencies: [highest] 29 | experimental: [false] 30 | os: [ubuntu-latest] 31 | include: 32 | - php-version: "7.2" 33 | dependencies: lowest 34 | os: ubuntu-latest 35 | experimental: false 36 | - php-version: "8.3" 37 | dependencies: lowest 38 | os: ubuntu-latest 39 | experimental: false 40 | - php-version: "8.3" 41 | dependencies: highest 42 | os: windows-latest 43 | experimental: false 44 | 45 | steps: 46 | - uses: actions/checkout@v4 47 | 48 | - uses: shivammathur/setup-php@v2 49 | with: 50 | php-version: "${{ matrix.php-version }}" 51 | coverage: none 52 | 53 | - uses: ramsey/composer-install@v3 54 | with: 55 | dependency-versions: ${{ matrix.dependencies }} 56 | 57 | - name: Run tests 58 | run: composer test 59 | -------------------------------------------------------------------------------- /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | name: "PHP Lint" 2 | 3 | on: 4 | - push 5 | - pull_request 6 | 7 | permissions: 8 | contents: read 9 | 10 | jobs: 11 | tests: 12 | name: "Lint" 13 | 14 | runs-on: ubuntu-latest 15 | 16 | strategy: 17 | matrix: 18 | php-version: 19 | - "7.2" 20 | - "nightly" 21 | 22 | steps: 23 | - uses: actions/checkout@v4 24 | 25 | - uses: shivammathur/setup-php@v2 26 | with: 27 | php-version: "${{ matrix.php-version }}" 28 | coverage: none 29 | 30 | - name: "Lint PHP files" 31 | run: | 32 | hasErrors=0 33 | for f in $(find src/ tests/ -type f -name '*.php' ! -path '*/vendor/*' ! -path '*/Fixtures/*') 34 | do 35 | { error="$(php -derror_reporting=-1 -ddisplay_errors=1 -l -f $f 2>&1 1>&3 3>&-)"; } 3>&1; 36 | if [ "$error" != "" ]; then 37 | while IFS= read -r line; do echo "::error file=$f::$line"; done <<< "$error" 38 | hasErrors=1 39 | fi 40 | done 41 | if [ $hasErrors -eq 1 ]; then 42 | exit 1 43 | fi 44 | -------------------------------------------------------------------------------- /.github/workflows/phpstan.yml: -------------------------------------------------------------------------------- 1 | name: "PHPStan" 2 | 3 | on: 4 | - push 5 | - pull_request 6 | 7 | permissions: 8 | contents: read 9 | 10 | jobs: 11 | tests: 12 | name: "PHPStan" 13 | 14 | runs-on: ubuntu-latest 15 | 16 | strategy: 17 | matrix: 18 | php-version: 19 | - "7.2" 20 | - "8.3" 21 | 22 | steps: 23 | - uses: actions/checkout@v4 24 | 25 | - uses: shivammathur/setup-php@v2 26 | with: 27 | php-version: "${{ matrix.php-version }}" 28 | coverage: none 29 | 30 | - uses: ramsey/composer-install@v3 31 | with: 32 | dependency-versions: highest 33 | 34 | - name: Run PHPStan 35 | run: composer phpstan 36 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Kyle Robinson Young 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is furnished 8 | to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "composer/installers", 3 | "type": "composer-plugin", 4 | "license": "MIT", 5 | "description": "A multi-framework Composer library installer", 6 | "keywords": [ 7 | "installer", 8 | "AGL", 9 | "AnnotateCms", 10 | "Attogram", 11 | "Bitrix", 12 | "CakePHP", 13 | "Chef", 14 | "Cockpit", 15 | "CodeIgniter", 16 | "concrete5", 17 | "ConcreteCMS", 18 | "Croogo", 19 | "DokuWiki", 20 | "Dolibarr", 21 | "Drupal", 22 | "Elgg", 23 | "Eliasis", 24 | "ExpressionEngine", 25 | "eZ Platform", 26 | "FuelPHP", 27 | "Grav", 28 | "Hurad", 29 | "ImageCMS", 30 | "iTop", 31 | "Kanboard", 32 | "Known", 33 | "Kohana", 34 | "Lan Management System", 35 | "Laravel", 36 | "Lavalite", 37 | "Lithium", 38 | "Magento", 39 | "majima", 40 | "Mako", 41 | "MantisBT", 42 | "Matomo", 43 | "Mautic", 44 | "Maya", 45 | "MODX", 46 | "MODX Evo", 47 | "MediaWiki", 48 | "Miaoxing", 49 | "OXID", 50 | "osclass", 51 | "MODULEWork", 52 | "Moodle", 53 | "Pantheon", 54 | "Piwik", 55 | "pxcms", 56 | "phpBB", 57 | "Plentymarkets", 58 | "PPI", 59 | "Puppet", 60 | "Porto", 61 | "ProcessWire", 62 | "RadPHP", 63 | "ReIndex", 64 | "Roundcube", 65 | "shopware", 66 | "SilverStripe", 67 | "SMF", 68 | "Starbug", 69 | "SyDES", 70 | "Sylius", 71 | "TastyIgniter", 72 | "Thelia", 73 | "WHMCS", 74 | "WolfCMS", 75 | "WordPress", 76 | "YAWIK", 77 | "Zend", 78 | "Zikula" 79 | ], 80 | "authors": [ 81 | { 82 | "name": "Kyle Robinson Young", 83 | "email": "kyle@dontkry.com", 84 | "homepage": "https://github.com/shama" 85 | } 86 | ], 87 | "autoload": { 88 | "psr-4": { "Composer\\Installers\\": "src/Composer/Installers" } 89 | }, 90 | "autoload-dev": { 91 | "psr-4": { "Composer\\Installers\\Test\\": "tests/Composer/Installers/Test" } 92 | }, 93 | "extra": { 94 | "class": "Composer\\Installers\\Plugin", 95 | "branch-alias": { 96 | "dev-main": "2.x-dev" 97 | }, 98 | "plugin-modifies-install-path": true 99 | }, 100 | "require": { 101 | "php": "^7.2 || ^8.0", 102 | "composer-plugin-api": "^1.0 || ^2.0" 103 | }, 104 | "require-dev": { 105 | "composer/composer": "^1.10.27 || ^2.7.8", 106 | "composer/semver": "^1.7.2 || ^3.4.2", 107 | "phpunit/phpunit": "^8.5.39 || ^9.6.20", 108 | "phpstan/phpstan": "^1.11.11", 109 | "symfony/process": "^5 || ^6 || ^7.1.3", 110 | "phpstan/phpstan-phpunit": "^1.4" 111 | }, 112 | "scripts": { 113 | "test": "@php phpunit", 114 | "phpstan": "@php phpstan analyse" 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /src/Composer/Installers/AglInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'module' => 'More/{$name}/', 10 | ); 11 | 12 | /** 13 | * Format package name to CamelCase 14 | */ 15 | public function inflectPackageVars(array $vars): array 16 | { 17 | $name = preg_replace_callback('/(?:^|_|-)(.?)/', function ($matches) { 18 | return strtoupper($matches[1]); 19 | }, $vars['name']); 20 | 21 | if (null === $name) { 22 | throw new \RuntimeException('Failed to run preg_replace_callback: '.preg_last_error()); 23 | } 24 | 25 | $vars['name'] = $name; 26 | 27 | return $vars; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Composer/Installers/AkauntingInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'module' => 'modules/{$name}', 10 | ); 11 | 12 | /** 13 | * Format package name to CamelCase 14 | */ 15 | public function inflectPackageVars(array $vars): array 16 | { 17 | $vars['name'] = strtolower($this->pregReplace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name'])); 18 | $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); 19 | $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); 20 | 21 | return $vars; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Composer/Installers/AnnotateCmsInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'module' => 'addons/modules/{$name}/', 10 | 'component' => 'addons/components/{$name}/', 11 | 'service' => 'addons/services/{$name}/', 12 | ); 13 | } 14 | -------------------------------------------------------------------------------- /src/Composer/Installers/AsgardInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'module' => 'Modules/{$name}/', 10 | 'theme' => 'Themes/{$name}/' 11 | ); 12 | 13 | /** 14 | * Format package name. 15 | * 16 | * For package type asgard-module, cut off a trailing '-plugin' if present. 17 | * 18 | * For package type asgard-theme, cut off a trailing '-theme' if present. 19 | */ 20 | public function inflectPackageVars(array $vars): array 21 | { 22 | if ($vars['type'] === 'asgard-module') { 23 | return $this->inflectPluginVars($vars); 24 | } 25 | 26 | if ($vars['type'] === 'asgard-theme') { 27 | return $this->inflectThemeVars($vars); 28 | } 29 | 30 | return $vars; 31 | } 32 | 33 | /** 34 | * @param array $vars 35 | * @return array 36 | */ 37 | protected function inflectPluginVars(array $vars): array 38 | { 39 | $vars['name'] = $this->pregReplace('/-module$/', '', $vars['name']); 40 | $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); 41 | $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); 42 | 43 | return $vars; 44 | } 45 | 46 | /** 47 | * @param array $vars 48 | * @return array 49 | */ 50 | protected function inflectThemeVars(array $vars): array 51 | { 52 | $vars['name'] = $this->pregReplace('/-theme$/', '', $vars['name']); 53 | $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); 54 | $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); 55 | 56 | return $vars; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/Composer/Installers/AttogramInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'module' => 'modules/{$name}/', 10 | ); 11 | } 12 | -------------------------------------------------------------------------------- /src/Composer/Installers/BaseInstaller.php: -------------------------------------------------------------------------------- 1 | */ 12 | protected $locations = array(); 13 | /** @var Composer */ 14 | protected $composer; 15 | /** @var PackageInterface */ 16 | protected $package; 17 | /** @var IOInterface */ 18 | protected $io; 19 | 20 | /** 21 | * Initializes base installer. 22 | */ 23 | public function __construct(PackageInterface $package, Composer $composer, IOInterface $io) 24 | { 25 | $this->composer = $composer; 26 | $this->package = $package; 27 | $this->io = $io; 28 | } 29 | 30 | /** 31 | * Return the install path based on package type. 32 | */ 33 | public function getInstallPath(PackageInterface $package, string $frameworkType = ''): string 34 | { 35 | $type = $this->package->getType(); 36 | 37 | $prettyName = $this->package->getPrettyName(); 38 | if (strpos($prettyName, '/') !== false) { 39 | list($vendor, $name) = explode('/', $prettyName); 40 | } else { 41 | $vendor = ''; 42 | $name = $prettyName; 43 | } 44 | 45 | $availableVars = $this->inflectPackageVars(compact('name', 'vendor', 'type')); 46 | 47 | $extra = $package->getExtra(); 48 | if (!empty($extra['installer-name'])) { 49 | $availableVars['name'] = $extra['installer-name']; 50 | } 51 | 52 | $extra = $this->composer->getPackage()->getExtra(); 53 | if (!empty($extra['installer-paths'])) { 54 | $customPath = $this->mapCustomInstallPaths($extra['installer-paths'], $prettyName, $type, $vendor); 55 | if ($customPath !== false) { 56 | return $this->templatePath($customPath, $availableVars); 57 | } 58 | } 59 | 60 | $packageType = substr($type, strlen($frameworkType) + 1); 61 | $locations = $this->getLocations($frameworkType); 62 | if (!isset($locations[$packageType])) { 63 | throw new \InvalidArgumentException(sprintf('Package type "%s" is not supported', $type)); 64 | } 65 | 66 | return $this->templatePath($locations[$packageType], $availableVars); 67 | } 68 | 69 | /** 70 | * For an installer to override to modify the vars per installer. 71 | * 72 | * @param array $vars This will normally receive array{name: string, vendor: string, type: string} 73 | * @return array 74 | */ 75 | public function inflectPackageVars(array $vars): array 76 | { 77 | return $vars; 78 | } 79 | 80 | /** 81 | * Gets the installer's locations 82 | * 83 | * @return array map of package types => install path 84 | */ 85 | public function getLocations(string $frameworkType) 86 | { 87 | return $this->locations; 88 | } 89 | 90 | /** 91 | * Replace vars in a path 92 | * 93 | * @param array $vars 94 | */ 95 | protected function templatePath(string $path, array $vars = array()): string 96 | { 97 | if (strpos($path, '{') !== false) { 98 | extract($vars); 99 | preg_match_all('@\{\$([A-Za-z0-9_]*)\}@i', $path, $matches); 100 | if (!empty($matches[1])) { 101 | foreach ($matches[1] as $var) { 102 | $path = str_replace('{$' . $var . '}', $$var, $path); 103 | } 104 | } 105 | } 106 | 107 | return $path; 108 | } 109 | 110 | /** 111 | * Search through a passed paths array for a custom install path. 112 | * 113 | * @param array $paths 114 | * @return string|false 115 | */ 116 | protected function mapCustomInstallPaths(array $paths, string $name, string $type, ?string $vendor = null) 117 | { 118 | foreach ($paths as $path => $names) { 119 | $names = (array) $names; 120 | if (in_array($name, $names) || in_array('type:' . $type, $names) || in_array('vendor:' . $vendor, $names)) { 121 | return $path; 122 | } 123 | } 124 | 125 | return false; 126 | } 127 | 128 | protected function pregReplace(string $pattern, string $replacement, string $subject): string 129 | { 130 | $result = preg_replace($pattern, $replacement, $subject); 131 | if (null === $result) { 132 | throw new \RuntimeException('Failed to run preg_replace with '.$pattern.': '.preg_last_error()); 133 | } 134 | 135 | return $result; 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /src/Composer/Installers/BitrixInstaller.php: -------------------------------------------------------------------------------- 1 | .`. 10 | * - `bitrix-d7-component` — copy the component to directory `bitrix/components//`. 11 | * - `bitrix-d7-template` — copy the template to directory `bitrix/templates/_`. 12 | * 13 | * You can set custom path to directory with Bitrix kernel in `composer.json`: 14 | * 15 | * ```json 16 | * { 17 | * "extra": { 18 | * "bitrix-dir": "s1/bitrix" 19 | * } 20 | * } 21 | * ``` 22 | * 23 | * @author Nik Samokhvalov 24 | * @author Denis Kulichkin 25 | */ 26 | class BitrixInstaller extends BaseInstaller 27 | { 28 | /** @var array */ 29 | protected $locations = array( 30 | 'module' => '{$bitrix_dir}/modules/{$name}/', // deprecated, remove on the major release (Backward compatibility will be broken) 31 | 'component' => '{$bitrix_dir}/components/{$name}/', // deprecated, remove on the major release (Backward compatibility will be broken) 32 | 'theme' => '{$bitrix_dir}/templates/{$name}/', // deprecated, remove on the major release (Backward compatibility will be broken) 33 | 'd7-module' => '{$bitrix_dir}/modules/{$vendor}.{$name}/', 34 | 'd7-component' => '{$bitrix_dir}/components/{$vendor}/{$name}/', 35 | 'd7-template' => '{$bitrix_dir}/templates/{$vendor}_{$name}/', 36 | ); 37 | 38 | /** 39 | * @var string[] Storage for informations about duplicates at all the time of installation packages. 40 | */ 41 | private static $checkedDuplicates = array(); 42 | 43 | public function inflectPackageVars(array $vars): array 44 | { 45 | /** @phpstan-ignore-next-line */ 46 | if ($this->composer->getPackage()) { 47 | $extra = $this->composer->getPackage()->getExtra(); 48 | 49 | if (isset($extra['bitrix-dir'])) { 50 | $vars['bitrix_dir'] = $extra['bitrix-dir']; 51 | } 52 | } 53 | 54 | if (!isset($vars['bitrix_dir'])) { 55 | $vars['bitrix_dir'] = 'bitrix'; 56 | } 57 | 58 | return parent::inflectPackageVars($vars); 59 | } 60 | 61 | /** 62 | * {@inheritdoc} 63 | */ 64 | protected function templatePath(string $path, array $vars = array()): string 65 | { 66 | $templatePath = parent::templatePath($path, $vars); 67 | $this->checkDuplicates($templatePath, $vars); 68 | 69 | return $templatePath; 70 | } 71 | 72 | /** 73 | * Duplicates search packages. 74 | * 75 | * @param array $vars 76 | */ 77 | protected function checkDuplicates(string $path, array $vars = array()): void 78 | { 79 | $packageType = substr($vars['type'], strlen('bitrix') + 1); 80 | $localDir = explode('/', $vars['bitrix_dir']); 81 | array_pop($localDir); 82 | $localDir[] = 'local'; 83 | $localDir = implode('/', $localDir); 84 | 85 | $oldPath = str_replace( 86 | array('{$bitrix_dir}', '{$name}'), 87 | array($localDir, $vars['name']), 88 | $this->locations[$packageType] 89 | ); 90 | 91 | if (in_array($oldPath, static::$checkedDuplicates)) { 92 | return; 93 | } 94 | 95 | if ($oldPath !== $path && file_exists($oldPath) && $this->io->isInteractive()) { 96 | $this->io->writeError(' Duplication of packages:'); 97 | $this->io->writeError(' Package ' . $oldPath . ' will be called instead package ' . $path . ''); 98 | 99 | while (true) { 100 | switch ($this->io->ask(' Delete ' . $oldPath . ' [y,n,?]? ', '?')) { 101 | case 'y': 102 | $fs = new Filesystem(); 103 | $fs->removeDirectory($oldPath); 104 | break 2; 105 | 106 | case 'n': 107 | break 2; 108 | 109 | case '?': 110 | default: 111 | $this->io->writeError(array( 112 | ' y - delete package ' . $oldPath . ' and to continue with the installation', 113 | ' n - don\'t delete and to continue with the installation', 114 | )); 115 | $this->io->writeError(' ? - print help'); 116 | break; 117 | } 118 | } 119 | } 120 | 121 | static::$checkedDuplicates[] = $oldPath; 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /src/Composer/Installers/BonefishInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'package' => 'Packages/{$vendor}/{$name}/' 10 | ); 11 | } 12 | -------------------------------------------------------------------------------- /src/Composer/Installers/BotbleInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'plugin' => 'platform/plugins/{$name}/', 10 | 'theme' => 'platform/themes/{$name}/', 11 | ); 12 | } 13 | -------------------------------------------------------------------------------- /src/Composer/Installers/CakePHPInstaller.php: -------------------------------------------------------------------------------- 1 | */ 11 | protected $locations = array( 12 | 'plugin' => 'Plugin/{$name}/', 13 | ); 14 | 15 | /** 16 | * Format package name to CamelCase 17 | */ 18 | public function inflectPackageVars(array $vars): array 19 | { 20 | if ($this->matchesCakeVersion('>=', '3.0.0')) { 21 | return $vars; 22 | } 23 | 24 | $nameParts = explode('/', $vars['name']); 25 | foreach ($nameParts as &$value) { 26 | $value = strtolower($this->pregReplace('/(?<=\\w)([A-Z])/', '_\\1', $value)); 27 | $value = str_replace(array('-', '_'), ' ', $value); 28 | $value = str_replace(' ', '', ucwords($value)); 29 | } 30 | $vars['name'] = implode('/', $nameParts); 31 | 32 | return $vars; 33 | } 34 | 35 | /** 36 | * Change the default plugin location when cakephp >= 3.0 37 | */ 38 | public function getLocations(string $frameworkType): array 39 | { 40 | if ($this->matchesCakeVersion('>=', '3.0.0')) { 41 | $this->locations['plugin'] = $this->composer->getConfig()->get('vendor-dir') . '/{$vendor}/{$name}/'; 42 | } 43 | return $this->locations; 44 | } 45 | 46 | /** 47 | * Check if CakePHP version matches against a version 48 | * 49 | * @phpstan-param '='|'=='|'<'|'<='|'>'|'>='|'<>'|'!=' $matcher 50 | */ 51 | protected function matchesCakeVersion(string $matcher, string $version): bool 52 | { 53 | $repositoryManager = $this->composer->getRepositoryManager(); 54 | /** @phpstan-ignore-next-line */ 55 | if (!$repositoryManager) { 56 | return false; 57 | } 58 | 59 | $repos = $repositoryManager->getLocalRepository(); 60 | /** @phpstan-ignore-next-line */ 61 | if (!$repos) { 62 | return false; 63 | } 64 | 65 | return $repos->findPackage('cakephp/cakephp', new Constraint($matcher, $version)) !== null; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/Composer/Installers/ChefInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'cookbook' => 'Chef/{$vendor}/{$name}/', 10 | 'role' => 'Chef/roles/{$name}/', 11 | ); 12 | } 13 | -------------------------------------------------------------------------------- /src/Composer/Installers/CiviCrmInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'ext' => 'ext/{$name}/' 10 | ); 11 | } 12 | -------------------------------------------------------------------------------- /src/Composer/Installers/ClanCatsFrameworkInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'ship' => 'CCF/orbit/{$name}/', 10 | 'theme' => 'CCF/app/themes/{$name}/', 11 | ); 12 | } 13 | -------------------------------------------------------------------------------- /src/Composer/Installers/CockpitInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'module' => 'cockpit/modules/addons/{$name}/', 10 | ); 11 | 12 | /** 13 | * Format module name. 14 | * 15 | * Strip `module-` prefix from package name. 16 | */ 17 | public function inflectPackageVars(array $vars): array 18 | { 19 | if ($vars['type'] == 'cockpit-module') { 20 | return $this->inflectModuleVars($vars); 21 | } 22 | 23 | return $vars; 24 | } 25 | 26 | /** 27 | * @param array $vars 28 | * @return array 29 | */ 30 | public function inflectModuleVars(array $vars): array 31 | { 32 | $vars['name'] = ucfirst($this->pregReplace('/cockpit-/i', '', $vars['name'])); 33 | 34 | return $vars; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Composer/Installers/CodeIgniterInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'library' => 'application/libraries/{$name}/', 10 | 'third-party' => 'application/third_party/{$name}/', 11 | 'module' => 'application/modules/{$name}/', 12 | ); 13 | } 14 | -------------------------------------------------------------------------------- /src/Composer/Installers/Concrete5Installer.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'core' => 'concrete/', 10 | 'block' => 'application/blocks/{$name}/', 11 | 'package' => 'packages/{$name}/', 12 | 'theme' => 'application/themes/{$name}/', 13 | 'update' => 'updates/{$name}/', 14 | ); 15 | } 16 | -------------------------------------------------------------------------------- /src/Composer/Installers/ConcreteCMSInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'core' => 'concrete/', 10 | 'block' => 'application/blocks/{$name}/', 11 | 'package' => 'packages/{$name}/', 12 | 'theme' => 'application/themes/{$name}/', 13 | 'update' => 'updates/{$name}/', 14 | ); 15 | } 16 | -------------------------------------------------------------------------------- /src/Composer/Installers/CroogoInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'plugin' => 'Plugin/{$name}/', 10 | 'theme' => 'View/Themed/{$name}/', 11 | ); 12 | 13 | /** 14 | * Format package name to CamelCase 15 | */ 16 | public function inflectPackageVars(array $vars): array 17 | { 18 | $vars['name'] = strtolower(str_replace(array('-', '_'), ' ', $vars['name'])); 19 | $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); 20 | 21 | return $vars; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Composer/Installers/DecibelInstaller.php: -------------------------------------------------------------------------------- 1 | */ 9 | protected $locations = array( 10 | 'app' => 'app/{$name}/', 11 | ); 12 | } 13 | -------------------------------------------------------------------------------- /src/Composer/Installers/DframeInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'module' => 'modules/{$vendor}/{$name}/', 10 | ); 11 | } 12 | -------------------------------------------------------------------------------- /src/Composer/Installers/DokuWikiInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'plugin' => 'lib/plugins/{$name}/', 10 | 'template' => 'lib/tpl/{$name}/', 11 | ); 12 | 13 | /** 14 | * Format package name. 15 | * 16 | * For package type dokuwiki-plugin, cut off a trailing '-plugin', 17 | * or leading dokuwiki_ if present. 18 | * 19 | * For package type dokuwiki-template, cut off a trailing '-template' if present. 20 | */ 21 | public function inflectPackageVars(array $vars): array 22 | { 23 | if ($vars['type'] === 'dokuwiki-plugin') { 24 | return $this->inflectPluginVars($vars); 25 | } 26 | 27 | if ($vars['type'] === 'dokuwiki-template') { 28 | return $this->inflectTemplateVars($vars); 29 | } 30 | 31 | return $vars; 32 | } 33 | 34 | /** 35 | * @param array $vars 36 | * @return array 37 | */ 38 | protected function inflectPluginVars(array $vars): array 39 | { 40 | $vars['name'] = $this->pregReplace('/-plugin$/', '', $vars['name']); 41 | $vars['name'] = $this->pregReplace('/^dokuwiki_?-?/', '', $vars['name']); 42 | 43 | return $vars; 44 | } 45 | 46 | /** 47 | * @param array $vars 48 | * @return array 49 | */ 50 | protected function inflectTemplateVars(array $vars): array 51 | { 52 | $vars['name'] = $this->pregReplace('/-template$/', '', $vars['name']); 53 | $vars['name'] = $this->pregReplace('/^dokuwiki_?-?/', '', $vars['name']); 54 | 55 | return $vars; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/Composer/Installers/DolibarrInstaller.php: -------------------------------------------------------------------------------- 1 | 10 | */ 11 | class DolibarrInstaller extends BaseInstaller 12 | { 13 | //TODO: Add support for scripts and themes 14 | /** @var array */ 15 | protected $locations = array( 16 | 'module' => 'htdocs/custom/{$name}/', 17 | ); 18 | } 19 | -------------------------------------------------------------------------------- /src/Composer/Installers/DrupalInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'core' => 'core/', 10 | 'module' => 'modules/{$name}/', 11 | 'theme' => 'themes/{$name}/', 12 | 'library' => 'libraries/{$name}/', 13 | 'profile' => 'profiles/{$name}/', 14 | 'database-driver' => 'drivers/lib/Drupal/Driver/Database/{$name}/', 15 | 'drush' => 'drush/{$name}/', 16 | 'custom-theme' => 'themes/custom/{$name}/', 17 | 'custom-module' => 'modules/custom/{$name}/', 18 | 'custom-profile' => 'profiles/custom/{$name}/', 19 | 'drupal-multisite' => 'sites/{$name}/', 20 | 'console' => 'console/{$name}/', 21 | 'console-language' => 'console/language/{$name}/', 22 | 'config' => 'config/sync/', 23 | 'recipe' => 'recipes/{$name}', 24 | ); 25 | } 26 | -------------------------------------------------------------------------------- /src/Composer/Installers/ElggInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'plugin' => 'mod/{$name}/', 10 | ); 11 | } 12 | -------------------------------------------------------------------------------- /src/Composer/Installers/EliasisInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'component' => 'components/{$name}/', 10 | 'module' => 'modules/{$name}/', 11 | 'plugin' => 'plugins/{$name}/', 12 | 'template' => 'templates/{$name}/', 13 | ); 14 | } 15 | -------------------------------------------------------------------------------- /src/Composer/Installers/ExpressionEngineInstaller.php: -------------------------------------------------------------------------------- 1 | */ 10 | private $ee2Locations = array( 11 | 'addon' => 'system/expressionengine/third_party/{$name}/', 12 | 'theme' => 'themes/third_party/{$name}/', 13 | ); 14 | 15 | /** @var array */ 16 | private $ee3Locations = array( 17 | 'addon' => 'system/user/addons/{$name}/', 18 | 'theme' => 'themes/user/{$name}/', 19 | ); 20 | 21 | public function getLocations(string $frameworkType): array 22 | { 23 | if ($frameworkType === 'ee2') { 24 | $this->locations = $this->ee2Locations; 25 | } else { 26 | $this->locations = $this->ee3Locations; 27 | } 28 | 29 | return $this->locations; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Composer/Installers/EzPlatformInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'meta-assets' => 'web/assets/ezplatform/', 10 | 'assets' => 'web/assets/ezplatform/{$name}/', 11 | ); 12 | } 13 | -------------------------------------------------------------------------------- /src/Composer/Installers/ForkCMSInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = [ 9 | 'module' => 'src/Modules/{$name}/', 10 | 'theme' => 'src/Themes/{$name}/' 11 | ]; 12 | 13 | /** 14 | * Format package name. 15 | * 16 | * For package type fork-cms-module, cut off a trailing '-plugin' if present. 17 | * 18 | * For package type fork-cms-theme, cut off a trailing '-theme' if present. 19 | */ 20 | public function inflectPackageVars(array $vars): array 21 | { 22 | if ($vars['type'] === 'fork-cms-module') { 23 | return $this->inflectModuleVars($vars); 24 | } 25 | 26 | if ($vars['type'] === 'fork-cms-theme') { 27 | return $this->inflectThemeVars($vars); 28 | } 29 | 30 | return $vars; 31 | } 32 | 33 | /** 34 | * @param array $vars 35 | * @return array 36 | */ 37 | protected function inflectModuleVars(array $vars): array 38 | { 39 | $vars['name'] = $this->pregReplace('/^fork-cms-|-module|ForkCMS|ForkCms|Forkcms|forkcms|Module$/', '', $vars['name']); 40 | $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); // replace hyphens with spaces 41 | $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); // make module name camelcased 42 | 43 | return $vars; 44 | } 45 | 46 | /** 47 | * @param array $vars 48 | * @return array 49 | */ 50 | protected function inflectThemeVars(array $vars): array 51 | { 52 | $vars['name'] = $this->pregReplace('/^fork-cms-|-theme|ForkCMS|ForkCms|Forkcms|forkcms|Theme$/', '', $vars['name']); 53 | $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); // replace hyphens with spaces 54 | $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); // make theme name camelcased 55 | 56 | return $vars; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/Composer/Installers/FuelInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'module' => 'fuel/app/modules/{$name}/', 10 | 'package' => 'fuel/packages/{$name}/', 11 | 'theme' => 'fuel/app/themes/{$name}/', 12 | ); 13 | } 14 | -------------------------------------------------------------------------------- /src/Composer/Installers/FuelphpInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'component' => 'components/{$name}/', 10 | ); 11 | } 12 | -------------------------------------------------------------------------------- /src/Composer/Installers/GravInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'plugin' => 'user/plugins/{$name}/', 10 | 'theme' => 'user/themes/{$name}/', 11 | ); 12 | 13 | /** 14 | * Format package name 15 | */ 16 | public function inflectPackageVars(array $vars): array 17 | { 18 | $restrictedWords = implode('|', array_keys($this->locations)); 19 | 20 | $vars['name'] = strtolower($vars['name']); 21 | $vars['name'] = $this->pregReplace( 22 | '/^(?:grav-)?(?:(?:'.$restrictedWords.')-)?(.*?)(?:-(?:'.$restrictedWords.'))?$/ui', 23 | '$1', 24 | $vars['name'] 25 | ); 26 | 27 | return $vars; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Composer/Installers/HuradInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'plugin' => 'plugins/{$name}/', 10 | 'theme' => 'plugins/{$name}/', 11 | ); 12 | 13 | /** 14 | * Format package name to CamelCase 15 | */ 16 | public function inflectPackageVars(array $vars): array 17 | { 18 | $nameParts = explode('/', $vars['name']); 19 | foreach ($nameParts as &$value) { 20 | $value = strtolower($this->pregReplace('/(?<=\\w)([A-Z])/', '_\\1', $value)); 21 | $value = str_replace(array('-', '_'), ' ', $value); 22 | $value = str_replace(' ', '', ucwords($value)); 23 | } 24 | $vars['name'] = implode('/', $nameParts); 25 | return $vars; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Composer/Installers/ImageCMSInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'template' => 'templates/{$name}/', 10 | 'module' => 'application/modules/{$name}/', 11 | 'library' => 'application/libraries/{$name}/', 12 | ); 13 | } 14 | -------------------------------------------------------------------------------- /src/Composer/Installers/Installer.php: -------------------------------------------------------------------------------- 1 | 21 | */ 22 | private $supportedTypes = array( 23 | 'akaunting' => 'AkauntingInstaller', 24 | 'asgard' => 'AsgardInstaller', 25 | 'attogram' => 'AttogramInstaller', 26 | 'agl' => 'AglInstaller', 27 | 'annotatecms' => 'AnnotateCmsInstaller', 28 | 'bitrix' => 'BitrixInstaller', 29 | 'botble' => 'BotbleInstaller', 30 | 'bonefish' => 'BonefishInstaller', 31 | 'cakephp' => 'CakePHPInstaller', 32 | 'chef' => 'ChefInstaller', 33 | 'civicrm' => 'CiviCrmInstaller', 34 | 'ccframework' => 'ClanCatsFrameworkInstaller', 35 | 'cockpit' => 'CockpitInstaller', 36 | 'codeigniter' => 'CodeIgniterInstaller', 37 | 'concrete5' => 'Concrete5Installer', 38 | 'concretecms' => 'ConcreteCMSInstaller', 39 | 'croogo' => 'CroogoInstaller', 40 | 'dframe' => 'DframeInstaller', 41 | 'dokuwiki' => 'DokuWikiInstaller', 42 | 'dolibarr' => 'DolibarrInstaller', 43 | 'decibel' => 'DecibelInstaller', 44 | 'drupal' => 'DrupalInstaller', 45 | 'elgg' => 'ElggInstaller', 46 | 'eliasis' => 'EliasisInstaller', 47 | 'ee3' => 'ExpressionEngineInstaller', 48 | 'ee2' => 'ExpressionEngineInstaller', 49 | 'ezplatform' => 'EzPlatformInstaller', 50 | 'fork' => 'ForkCMSInstaller', 51 | 'fuel' => 'FuelInstaller', 52 | 'fuelphp' => 'FuelphpInstaller', 53 | 'grav' => 'GravInstaller', 54 | 'hurad' => 'HuradInstaller', 55 | 'tastyigniter' => 'TastyIgniterInstaller', 56 | 'imagecms' => 'ImageCMSInstaller', 57 | 'itop' => 'ItopInstaller', 58 | 'kanboard' => 'KanboardInstaller', 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 | 'matomo' => 'MatomoInstaller', 71 | 'maya' => 'MayaInstaller', 72 | 'mautic' => 'MauticInstaller', 73 | 'mediawiki' => 'MediaWikiInstaller', 74 | 'miaoxing' => 'MiaoxingInstaller', 75 | 'microweber' => 'MicroweberInstaller', 76 | 'modulework' => 'MODULEWorkInstaller', 77 | 'modx' => 'ModxInstaller', 78 | 'modxevo' => 'MODXEvoInstaller', 79 | 'moodle' => 'MoodleInstaller', 80 | 'october' => 'OctoberInstaller', 81 | 'ontowiki' => 'OntoWikiInstaller', 82 | 'oxid' => 'OxidInstaller', 83 | 'osclass' => 'OsclassInstaller', 84 | 'pxcms' => 'PxcmsInstaller', 85 | 'phpbb' => 'PhpBBInstaller', 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 | 'tao' => 'TaoInstaller', 107 | 'thelia' => 'TheliaInstaller', 108 | 'tusk' => 'TuskInstaller', 109 | 'userfrosting' => 'UserFrostingInstaller', 110 | 'vanilla' => 'VanillaInstaller', 111 | 'whmcs' => 'WHMCSInstaller', 112 | 'winter' => 'WinterInstaller', 113 | 'wolfcms' => 'WolfCMSInstaller', 114 | 'wordpress' => 'WordPressInstaller', 115 | 'yawik' => 'YawikInstaller', 116 | 'zend' => 'ZendInstaller', 117 | 'zikula' => 'ZikulaInstaller', 118 | 'prestashop' => 'PrestashopInstaller' 119 | ); 120 | 121 | /** 122 | * Disables installers specified in main composer extra installer-disable 123 | * list 124 | */ 125 | public function __construct( 126 | IOInterface $io, 127 | Composer $composer, 128 | string $type = 'library', 129 | ?Filesystem $filesystem = null, 130 | ?BinaryInstaller $binaryInstaller = null 131 | ) { 132 | parent::__construct($io, $composer, $type, $filesystem, $binaryInstaller); 133 | $this->removeDisabledInstallers(); 134 | } 135 | 136 | /** 137 | * {@inheritDoc} 138 | */ 139 | public function getInstallPath(PackageInterface $package) 140 | { 141 | $type = $package->getType(); 142 | $frameworkType = $this->findFrameworkType($type); 143 | 144 | if ($frameworkType === false) { 145 | throw new \InvalidArgumentException( 146 | 'Sorry the package type of this package is not yet supported.' 147 | ); 148 | } 149 | 150 | $class = 'Composer\\Installers\\' . $this->supportedTypes[$frameworkType]; 151 | /** 152 | * @var BaseInstaller 153 | */ 154 | $installer = new $class($package, $this->composer, $this->getIO()); 155 | 156 | $path = $installer->getInstallPath($package, $frameworkType); 157 | if (!$this->filesystem->isAbsolutePath($path)) { 158 | $path = getcwd() . '/' . $path; 159 | } 160 | 161 | return $path; 162 | } 163 | 164 | public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package) 165 | { 166 | $installPath = $this->getPackageBasePath($package); 167 | $io = $this->io; 168 | $outputStatus = function () use ($io, $installPath) { 169 | $io->write(sprintf('Deleting %s - %s', $installPath, !file_exists($installPath) ? 'deleted' : 'not deleted')); 170 | }; 171 | 172 | $promise = parent::uninstall($repo, $package); 173 | 174 | // Composer v2 might return a promise here 175 | if ($promise instanceof PromiseInterface) { 176 | return $promise->then($outputStatus); 177 | } 178 | 179 | // If not, execute the code right away as parent::uninstall executed synchronously (composer v1, or v2 without async) 180 | $outputStatus(); 181 | 182 | return null; 183 | } 184 | 185 | /** 186 | * {@inheritDoc} 187 | * 188 | * @param string $packageType 189 | */ 190 | public function supports($packageType) 191 | { 192 | $frameworkType = $this->findFrameworkType($packageType); 193 | 194 | if ($frameworkType === false) { 195 | return false; 196 | } 197 | 198 | $locationPattern = $this->getLocationPattern($frameworkType); 199 | 200 | return preg_match('#' . $frameworkType . '-' . $locationPattern . '#', $packageType, $matches) === 1; 201 | } 202 | 203 | /** 204 | * Finds a supported framework type if it exists and returns it 205 | * 206 | * @return string|false 207 | */ 208 | protected function findFrameworkType(string $type) 209 | { 210 | krsort($this->supportedTypes); 211 | 212 | foreach ($this->supportedTypes as $key => $val) { 213 | if ($key === substr($type, 0, strlen($key))) { 214 | return substr($type, 0, strlen($key)); 215 | } 216 | } 217 | 218 | return false; 219 | } 220 | 221 | /** 222 | * Get the second part of the regular expression to check for support of a 223 | * package type 224 | */ 225 | protected function getLocationPattern(string $frameworkType): string 226 | { 227 | $pattern = null; 228 | if (!empty($this->supportedTypes[$frameworkType])) { 229 | $frameworkClass = 'Composer\\Installers\\' . $this->supportedTypes[$frameworkType]; 230 | /** @var BaseInstaller $framework */ 231 | $framework = new $frameworkClass(new Package('dummy/pkg', '1.0.0.0', '1.0.0'), $this->composer, $this->getIO()); 232 | $locations = array_keys($framework->getLocations($frameworkType)); 233 | if ($locations) { 234 | $pattern = '(' . implode('|', $locations) . ')'; 235 | } 236 | } 237 | 238 | return $pattern ?: '(\w+)'; 239 | } 240 | 241 | private function getIO(): IOInterface 242 | { 243 | return $this->io; 244 | } 245 | 246 | /** 247 | * Look for installers set to be disabled in composer's extra config and 248 | * remove them from the list of supported installers. 249 | * 250 | * Globals: 251 | * - true, "all", and "*" - disable all installers. 252 | * - false - enable all installers (useful with 253 | * wikimedia/composer-merge-plugin or similar) 254 | */ 255 | protected function removeDisabledInstallers(): void 256 | { 257 | $extra = $this->composer->getPackage()->getExtra(); 258 | 259 | if (!isset($extra['installer-disable']) || $extra['installer-disable'] === false) { 260 | // No installers are disabled 261 | return; 262 | } 263 | 264 | // Get installers to disable 265 | $disable = $extra['installer-disable']; 266 | 267 | // Ensure $disabled is an array 268 | if (!is_array($disable)) { 269 | $disable = array($disable); 270 | } 271 | 272 | // Check which installers should be disabled 273 | $all = array(true, "all", "*"); 274 | $intersect = array_intersect($all, $disable); 275 | if (!empty($intersect)) { 276 | // Disable all installers 277 | $this->supportedTypes = array(); 278 | return; 279 | } 280 | 281 | // Disable specified installers 282 | foreach ($disable as $key => $installer) { 283 | if (is_string($installer) && key_exists($installer, $this->supportedTypes)) { 284 | unset($this->supportedTypes[$installer]); 285 | } 286 | } 287 | } 288 | } 289 | -------------------------------------------------------------------------------- /src/Composer/Installers/ItopInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'extension' => 'extensions/{$name}/', 10 | ); 11 | } 12 | -------------------------------------------------------------------------------- /src/Composer/Installers/KanboardInstaller.php: -------------------------------------------------------------------------------- 1 | */ 17 | protected $locations = array( 18 | 'plugin' => 'plugins/{$name}/', 19 | ); 20 | } 21 | -------------------------------------------------------------------------------- /src/Composer/Installers/KnownInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'plugin' => 'IdnoPlugins/{$name}/', 10 | 'theme' => 'Themes/{$name}/', 11 | 'console' => 'ConsolePlugins/{$name}/', 12 | ); 13 | } 14 | -------------------------------------------------------------------------------- /src/Composer/Installers/KodiCMSInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'plugin' => 'cms/plugins/{$name}/', 10 | 'media' => 'cms/media/vendor/{$name}/' 11 | ); 12 | } 13 | -------------------------------------------------------------------------------- /src/Composer/Installers/KohanaInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'module' => 'modules/{$name}/', 10 | ); 11 | } 12 | -------------------------------------------------------------------------------- /src/Composer/Installers/LanManagementSystemInstaller.php: -------------------------------------------------------------------------------- 1 | */ 9 | protected $locations = array( 10 | 'plugin' => 'plugins/{$name}/', 11 | 'template' => 'templates/{$name}/', 12 | 'document-template' => 'documents/templates/{$name}/', 13 | 'userpanel-module' => 'userpanel/modules/{$name}/', 14 | ); 15 | 16 | /** 17 | * Format package name to CamelCase 18 | */ 19 | public function inflectPackageVars(array $vars): array 20 | { 21 | $vars['name'] = strtolower($this->pregReplace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name'])); 22 | $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); 23 | $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); 24 | 25 | return $vars; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Composer/Installers/LaravelInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'library' => 'libraries/{$name}/', 10 | ); 11 | } 12 | -------------------------------------------------------------------------------- /src/Composer/Installers/LavaLiteInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'package' => 'packages/{$vendor}/{$name}/', 10 | 'theme' => 'public/themes/{$name}/', 11 | ); 12 | } 13 | -------------------------------------------------------------------------------- /src/Composer/Installers/LithiumInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'library' => 'libraries/{$name}/', 10 | 'source' => 'libraries/_source/{$name}/', 11 | ); 12 | } 13 | -------------------------------------------------------------------------------- /src/Composer/Installers/MODULEWorkInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'module' => 'modules/{$name}/', 10 | ); 11 | } 12 | -------------------------------------------------------------------------------- /src/Composer/Installers/MODXEvoInstaller.php: -------------------------------------------------------------------------------- 1 | */ 11 | protected $locations = array( 12 | 'snippet' => 'assets/snippets/{$name}/', 13 | 'plugin' => 'assets/plugins/{$name}/', 14 | 'module' => 'assets/modules/{$name}/', 15 | 'template' => 'assets/templates/{$name}/', 16 | 'lib' => 'assets/lib/{$name}/' 17 | ); 18 | } 19 | -------------------------------------------------------------------------------- /src/Composer/Installers/MagentoInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'theme' => 'app/design/frontend/{$name}/', 10 | 'skin' => 'skin/frontend/default/{$name}/', 11 | 'library' => 'lib/{$name}/', 12 | ); 13 | } 14 | -------------------------------------------------------------------------------- /src/Composer/Installers/MajimaInstaller.php: -------------------------------------------------------------------------------- 1 | */ 12 | protected $locations = array( 13 | 'plugin' => 'plugins/{$name}/', 14 | ); 15 | 16 | /** 17 | * Transforms the names 18 | * 19 | * @param array $vars 20 | * @return array 21 | */ 22 | public function inflectPackageVars(array $vars): array 23 | { 24 | return $this->correctPluginName($vars); 25 | } 26 | 27 | /** 28 | * Change hyphenated names to camelcase 29 | * 30 | * @param array $vars 31 | * @return array 32 | */ 33 | private function correctPluginName(array $vars): array 34 | { 35 | $camelCasedName = preg_replace_callback('/(-[a-z])/', function ($matches) { 36 | return strtoupper($matches[0][1]); 37 | }, $vars['name']); 38 | 39 | if (null === $camelCasedName) { 40 | throw new \RuntimeException('Failed to run preg_replace_callback: '.preg_last_error()); 41 | } 42 | 43 | $vars['name'] = ucfirst($camelCasedName); 44 | return $vars; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Composer/Installers/MakoInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'package' => 'app/packages/{$name}/', 10 | ); 11 | } 12 | -------------------------------------------------------------------------------- /src/Composer/Installers/MantisBTInstaller.php: -------------------------------------------------------------------------------- 1 | */ 10 | protected $locations = array( 11 | 'plugin' => 'plugins/{$name}/', 12 | ); 13 | 14 | /** 15 | * Format package name to CamelCase 16 | */ 17 | public function inflectPackageVars(array $vars): array 18 | { 19 | $vars['name'] = strtolower($this->pregReplace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name'])); 20 | $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); 21 | $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); 22 | 23 | return $vars; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Composer/Installers/MatomoInstaller.php: -------------------------------------------------------------------------------- 1 | */ 13 | protected $locations = array( 14 | 'plugin' => 'plugins/{$name}/', 15 | ); 16 | 17 | /** 18 | * Format package name to CamelCase 19 | */ 20 | public function inflectPackageVars(array $vars): array 21 | { 22 | $vars['name'] = strtolower($this->pregReplace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name'])); 23 | $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); 24 | $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); 25 | 26 | return $vars; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Composer/Installers/MauticInstaller.php: -------------------------------------------------------------------------------- 1 | */ 10 | protected $locations = array( 11 | 'plugin' => 'plugins/{$name}/', 12 | 'theme' => 'themes/{$name}/', 13 | 'core' => 'app/', 14 | ); 15 | 16 | private function getDirectoryName(): string 17 | { 18 | $extra = $this->package->getExtra(); 19 | if (!empty($extra['install-directory-name'])) { 20 | return $extra['install-directory-name']; 21 | } 22 | 23 | return $this->toCamelCase($this->package->getPrettyName()); 24 | } 25 | 26 | private function toCamelCase(string $packageName): string 27 | { 28 | return str_replace(' ', '', ucwords(str_replace('-', ' ', basename($packageName)))); 29 | } 30 | 31 | /** 32 | * Format package name of mautic-plugins to CamelCase 33 | */ 34 | public function inflectPackageVars(array $vars): array 35 | { 36 | if ($vars['type'] == 'mautic-plugin' || $vars['type'] == 'mautic-theme') { 37 | $directoryName = $this->getDirectoryName(); 38 | $vars['name'] = $directoryName; 39 | } 40 | 41 | return $vars; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/Composer/Installers/MayaInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'module' => 'modules/{$name}/', 10 | ); 11 | 12 | /** 13 | * Format package name. 14 | * 15 | * For package type maya-module, cut off a trailing '-module' if present. 16 | */ 17 | public function inflectPackageVars(array $vars): array 18 | { 19 | if ($vars['type'] === 'maya-module') { 20 | return $this->inflectModuleVars($vars); 21 | } 22 | 23 | return $vars; 24 | } 25 | 26 | /** 27 | * @param array $vars 28 | * @return array 29 | */ 30 | protected function inflectModuleVars(array $vars): array 31 | { 32 | $vars['name'] = $this->pregReplace('/-module$/', '', $vars['name']); 33 | $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); 34 | $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); 35 | 36 | return $vars; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Composer/Installers/MediaWikiInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'core' => 'core/', 10 | 'extension' => 'extensions/{$name}/', 11 | 'skin' => 'skins/{$name}/', 12 | ); 13 | 14 | /** 15 | * Format package name. 16 | * 17 | * For package type mediawiki-extension, cut off a trailing '-extension' if present and transform 18 | * to CamelCase keeping existing uppercase chars. 19 | * 20 | * For package type mediawiki-skin, cut off a trailing '-skin' if present. 21 | */ 22 | public function inflectPackageVars(array $vars): array 23 | { 24 | if ($vars['type'] === 'mediawiki-extension') { 25 | return $this->inflectExtensionVars($vars); 26 | } 27 | 28 | if ($vars['type'] === 'mediawiki-skin') { 29 | return $this->inflectSkinVars($vars); 30 | } 31 | 32 | return $vars; 33 | } 34 | 35 | /** 36 | * @param array $vars 37 | * @return array 38 | */ 39 | protected function inflectExtensionVars(array $vars): array 40 | { 41 | $vars['name'] = $this->pregReplace('/-extension$/', '', $vars['name']); 42 | $vars['name'] = str_replace('-', ' ', $vars['name']); 43 | $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); 44 | 45 | return $vars; 46 | } 47 | 48 | /** 49 | * @param array $vars 50 | * @return array 51 | */ 52 | protected function inflectSkinVars(array $vars): array 53 | { 54 | $vars['name'] = $this->pregReplace('/-skin$/', '', $vars['name']); 55 | 56 | return $vars; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/Composer/Installers/MiaoxingInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'plugin' => 'plugins/{$name}/', 10 | ); 11 | } 12 | -------------------------------------------------------------------------------- /src/Composer/Installers/MicroweberInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'module' => 'userfiles/modules/{$install_item_dir}/', 10 | 'module-skin' => 'userfiles/modules/{$install_item_dir}/templates/', 11 | 'template' => 'userfiles/templates/{$install_item_dir}/', 12 | 'element' => 'userfiles/elements/{$install_item_dir}/', 13 | 'vendor' => 'vendor/{$install_item_dir}/', 14 | 'components' => 'components/{$install_item_dir}/' 15 | ); 16 | 17 | /** 18 | * Format package name. 19 | * 20 | * For package type microweber-module, cut off a trailing '-module' if present 21 | * 22 | * For package type microweber-template, cut off a trailing '-template' if present. 23 | */ 24 | public function inflectPackageVars(array $vars): array 25 | { 26 | if ($this->package->getTargetDir() !== null && $this->package->getTargetDir() !== '') { 27 | $vars['install_item_dir'] = $this->package->getTargetDir(); 28 | } else { 29 | $vars['install_item_dir'] = $vars['name']; 30 | if ($vars['type'] === 'microweber-template') { 31 | return $this->inflectTemplateVars($vars); 32 | } 33 | if ($vars['type'] === 'microweber-templates') { 34 | return $this->inflectTemplatesVars($vars); 35 | } 36 | if ($vars['type'] === 'microweber-core') { 37 | return $this->inflectCoreVars($vars); 38 | } 39 | if ($vars['type'] === 'microweber-adapter') { 40 | return $this->inflectCoreVars($vars); 41 | } 42 | if ($vars['type'] === 'microweber-module') { 43 | return $this->inflectModuleVars($vars); 44 | } 45 | if ($vars['type'] === 'microweber-modules') { 46 | return $this->inflectModulesVars($vars); 47 | } 48 | if ($vars['type'] === 'microweber-skin') { 49 | return $this->inflectSkinVars($vars); 50 | } 51 | if ($vars['type'] === 'microweber-element' or $vars['type'] === 'microweber-elements') { 52 | return $this->inflectElementVars($vars); 53 | } 54 | } 55 | 56 | return $vars; 57 | } 58 | 59 | /** 60 | * @param array $vars 61 | * @return array 62 | */ 63 | protected function inflectTemplateVars(array $vars): array 64 | { 65 | $vars['install_item_dir'] = $this->pregReplace('/-template$/', '', $vars['install_item_dir']); 66 | $vars['install_item_dir'] = $this->pregReplace('/template-$/', '', $vars['install_item_dir']); 67 | 68 | return $vars; 69 | } 70 | 71 | /** 72 | * @param array $vars 73 | * @return array 74 | */ 75 | protected function inflectTemplatesVars(array $vars): array 76 | { 77 | $vars['install_item_dir'] = $this->pregReplace('/-templates$/', '', $vars['install_item_dir']); 78 | $vars['install_item_dir'] = $this->pregReplace('/templates-$/', '', $vars['install_item_dir']); 79 | 80 | return $vars; 81 | } 82 | 83 | /** 84 | * @param array $vars 85 | * @return array 86 | */ 87 | protected function inflectCoreVars(array $vars): array 88 | { 89 | $vars['install_item_dir'] = $this->pregReplace('/-providers$/', '', $vars['install_item_dir']); 90 | $vars['install_item_dir'] = $this->pregReplace('/-provider$/', '', $vars['install_item_dir']); 91 | $vars['install_item_dir'] = $this->pregReplace('/-adapter$/', '', $vars['install_item_dir']); 92 | 93 | return $vars; 94 | } 95 | 96 | /** 97 | * @param array $vars 98 | * @return array 99 | */ 100 | protected function inflectModuleVars(array $vars): array 101 | { 102 | $vars['install_item_dir'] = $this->pregReplace('/-module$/', '', $vars['install_item_dir']); 103 | $vars['install_item_dir'] = $this->pregReplace('/module-$/', '', $vars['install_item_dir']); 104 | 105 | return $vars; 106 | } 107 | 108 | /** 109 | * @param array $vars 110 | * @return array 111 | */ 112 | protected function inflectModulesVars(array $vars): array 113 | { 114 | $vars['install_item_dir'] = $this->pregReplace('/-modules$/', '', $vars['install_item_dir']); 115 | $vars['install_item_dir'] = $this->pregReplace('/modules-$/', '', $vars['install_item_dir']); 116 | 117 | return $vars; 118 | } 119 | 120 | /** 121 | * @param array $vars 122 | * @return array 123 | */ 124 | protected function inflectSkinVars(array $vars): array 125 | { 126 | $vars['install_item_dir'] = $this->pregReplace('/-skin$/', '', $vars['install_item_dir']); 127 | $vars['install_item_dir'] = $this->pregReplace('/skin-$/', '', $vars['install_item_dir']); 128 | 129 | return $vars; 130 | } 131 | 132 | /** 133 | * @param array $vars 134 | * @return array 135 | */ 136 | protected function inflectElementVars(array $vars): array 137 | { 138 | $vars['install_item_dir'] = $this->pregReplace('/-elements$/', '', $vars['install_item_dir']); 139 | $vars['install_item_dir'] = $this->pregReplace('/elements-$/', '', $vars['install_item_dir']); 140 | $vars['install_item_dir'] = $this->pregReplace('/-element$/', '', $vars['install_item_dir']); 141 | $vars['install_item_dir'] = $this->pregReplace('/element-$/', '', $vars['install_item_dir']); 142 | 143 | return $vars; 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /src/Composer/Installers/ModxInstaller.php: -------------------------------------------------------------------------------- 1 | */ 11 | protected $locations = array( 12 | 'extra' => 'core/packages/{$name}/' 13 | ); 14 | } 15 | -------------------------------------------------------------------------------- /src/Composer/Installers/MoodleInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'mod' => 'mod/{$name}/', 10 | 'admin_report' => 'admin/report/{$name}/', 11 | 'atto' => 'lib/editor/atto/plugins/{$name}/', 12 | 'tool' => 'admin/tool/{$name}/', 13 | 'assignment' => 'mod/assignment/type/{$name}/', 14 | 'assignsubmission' => 'mod/assign/submission/{$name}/', 15 | 'assignfeedback' => 'mod/assign/feedback/{$name}/', 16 | 'antivirus' => 'lib/antivirus/{$name}/', 17 | 'auth' => 'auth/{$name}/', 18 | 'availability' => 'availability/condition/{$name}/', 19 | 'block' => 'blocks/{$name}/', 20 | 'booktool' => 'mod/book/tool/{$name}/', 21 | 'cachestore' => 'cache/stores/{$name}/', 22 | 'cachelock' => 'cache/locks/{$name}/', 23 | 'calendartype' => 'calendar/type/{$name}/', 24 | 'communication' => 'communication/provider/{$name}/', 25 | 'customfield' => 'customfield/field/{$name}/', 26 | 'fileconverter' => 'files/converter/{$name}/', 27 | 'format' => 'course/format/{$name}/', 28 | 'coursereport' => 'course/report/{$name}/', 29 | 'contenttype' => 'contentbank/contenttype/{$name}/', 30 | 'customcertelement' => 'mod/customcert/element/{$name}/', 31 | 'datafield' => 'mod/data/field/{$name}/', 32 | 'dataformat' => 'dataformat/{$name}/', 33 | 'datapreset' => 'mod/data/preset/{$name}/', 34 | 'editor' => 'lib/editor/{$name}/', 35 | 'enrol' => 'enrol/{$name}/', 36 | 'filter' => 'filter/{$name}/', 37 | 'forumreport' => 'mod/forum/report/{$name}/', 38 | 'gradeexport' => 'grade/export/{$name}/', 39 | 'gradeimport' => 'grade/import/{$name}/', 40 | 'gradereport' => 'grade/report/{$name}/', 41 | 'gradingform' => 'grade/grading/form/{$name}/', 42 | 'h5plib' => 'h5p/h5plib/{$name}/', 43 | 'local' => 'local/{$name}/', 44 | 'logstore' => 'admin/tool/log/store/{$name}/', 45 | 'ltisource' => 'mod/lti/source/{$name}/', 46 | 'ltiservice' => 'mod/lti/service/{$name}/', 47 | 'media' => 'media/player/{$name}/', 48 | 'message' => 'message/output/{$name}/', 49 | 'mlbackend' => 'lib/mlbackend/{$name}/', 50 | 'mnetservice' => 'mnet/service/{$name}/', 51 | 'paygw' => 'payment/gateway/{$name}/', 52 | 'plagiarism' => 'plagiarism/{$name}/', 53 | 'portfolio' => 'portfolio/{$name}/', 54 | 'qbank' => 'question/bank/{$name}/', 55 | 'qbehaviour' => 'question/behaviour/{$name}/', 56 | 'qformat' => 'question/format/{$name}/', 57 | 'qtype' => 'question/type/{$name}/', 58 | 'quizaccess' => 'mod/quiz/accessrule/{$name}/', 59 | 'quiz' => 'mod/quiz/report/{$name}/', 60 | 'report' => 'report/{$name}/', 61 | 'repository' => 'repository/{$name}/', 62 | 'scormreport' => 'mod/scorm/report/{$name}/', 63 | 'search' => 'search/engine/{$name}/', 64 | 'theme' => 'theme/{$name}/', 65 | 'tiny' => 'lib/editor/tiny/plugins/{$name}/', 66 | 'tinymce' => 'lib/editor/tinymce/plugins/{$name}/', 67 | 'profilefield' => 'user/profile/field/{$name}/', 68 | 'webservice' => 'webservice/{$name}/', 69 | 'workshopallocation' => 'mod/workshop/allocation/{$name}/', 70 | 'workshopeval' => 'mod/workshop/eval/{$name}/', 71 | 'workshopform' => 'mod/workshop/form/{$name}/' 72 | ); 73 | } 74 | -------------------------------------------------------------------------------- /src/Composer/Installers/OctoberInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'module' => 'modules/{$name}/', 10 | 'plugin' => 'plugins/{$vendor}/{$name}/', 11 | 'theme' => 'themes/{$vendor}-{$name}/' 12 | ); 13 | 14 | /** 15 | * Format package name. 16 | * 17 | * For package type october-plugin, cut off a trailing '-plugin' if present. 18 | * 19 | * For package type october-theme, cut off a trailing '-theme' if present. 20 | */ 21 | public function inflectPackageVars(array $vars): array 22 | { 23 | if ($vars['type'] === 'october-plugin') { 24 | return $this->inflectPluginVars($vars); 25 | } 26 | 27 | if ($vars['type'] === 'october-theme') { 28 | return $this->inflectThemeVars($vars); 29 | } 30 | 31 | return $vars; 32 | } 33 | 34 | /** 35 | * @param array $vars 36 | * @return array 37 | */ 38 | protected function inflectPluginVars(array $vars): array 39 | { 40 | $vars['name'] = $this->pregReplace('/^oc-|-plugin$/', '', $vars['name']); 41 | $vars['vendor'] = $this->pregReplace('/[^a-z0-9_]/i', '', $vars['vendor']); 42 | 43 | return $vars; 44 | } 45 | 46 | /** 47 | * @param array $vars 48 | * @return array 49 | */ 50 | protected function inflectThemeVars(array $vars): array 51 | { 52 | $vars['name'] = $this->pregReplace('/^oc-|-theme$/', '', $vars['name']); 53 | $vars['vendor'] = $this->pregReplace('/[^a-z0-9_]/i', '', $vars['vendor']); 54 | 55 | return $vars; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/Composer/Installers/OntoWikiInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'extension' => 'extensions/{$name}/', 10 | 'theme' => 'extensions/themes/{$name}/', 11 | 'translation' => 'extensions/translations/{$name}/', 12 | ); 13 | 14 | /** 15 | * Format package name to lower case and remove ".ontowiki" suffix 16 | */ 17 | public function inflectPackageVars(array $vars): array 18 | { 19 | $vars['name'] = strtolower($vars['name']); 20 | $vars['name'] = $this->pregReplace('/.ontowiki$/', '', $vars['name']); 21 | $vars['name'] = $this->pregReplace('/-theme$/', '', $vars['name']); 22 | $vars['name'] = $this->pregReplace('/-translation$/', '', $vars['name']); 23 | 24 | return $vars; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Composer/Installers/OsclassInstaller.php: -------------------------------------------------------------------------------- 1 | */ 9 | protected $locations = array( 10 | 'plugin' => 'oc-content/plugins/{$name}/', 11 | 'theme' => 'oc-content/themes/{$name}/', 12 | 'language' => 'oc-content/languages/{$name}/', 13 | ); 14 | } 15 | -------------------------------------------------------------------------------- /src/Composer/Installers/OxidInstaller.php: -------------------------------------------------------------------------------- 1 | .+)\/.+/'; 10 | 11 | /** @var array */ 12 | protected $locations = array( 13 | 'module' => 'modules/{$name}/', 14 | 'theme' => 'application/views/{$name}/', 15 | 'out' => 'out/{$name}/', 16 | ); 17 | 18 | public function getInstallPath(PackageInterface $package, string $frameworkType = ''): string 19 | { 20 | $installPath = parent::getInstallPath($package, $frameworkType); 21 | $type = $this->package->getType(); 22 | if ($type === 'oxid-module') { 23 | $this->prepareVendorDirectory($installPath); 24 | } 25 | return $installPath; 26 | } 27 | 28 | /** 29 | * Makes sure there is a vendormetadata.php file inside 30 | * the vendor folder if there is a vendor folder. 31 | */ 32 | protected function prepareVendorDirectory(string $installPath): void 33 | { 34 | $matches = ''; 35 | $hasVendorDirectory = preg_match(self::VENDOR_PATTERN, $installPath, $matches); 36 | if (!$hasVendorDirectory) { 37 | return; 38 | } 39 | 40 | $vendorDirectory = $matches['vendor']; 41 | $vendorPath = getcwd() . '/modules/' . $vendorDirectory; 42 | if (!file_exists($vendorPath)) { 43 | mkdir($vendorPath, 0755, true); 44 | } 45 | 46 | $vendorMetaDataPath = $vendorPath . '/vendormetadata.php'; 47 | touch($vendorMetaDataPath); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/Composer/Installers/PPIInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'module' => 'modules/{$name}/', 10 | ); 11 | } 12 | -------------------------------------------------------------------------------- /src/Composer/Installers/PantheonInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'script' => 'web/private/scripts/quicksilver/{$name}', 10 | 'module' => 'web/private/scripts/quicksilver/{$name}', 11 | ); 12 | } 13 | -------------------------------------------------------------------------------- /src/Composer/Installers/PhiftyInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'bundle' => 'bundles/{$name}/', 10 | 'library' => 'libraries/{$name}/', 11 | 'framework' => 'frameworks/{$name}/', 12 | ); 13 | } 14 | -------------------------------------------------------------------------------- /src/Composer/Installers/PhpBBInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'extension' => 'ext/{$vendor}/{$name}/', 10 | 'language' => 'language/{$name}/', 11 | 'style' => 'styles/{$name}/', 12 | ); 13 | } 14 | -------------------------------------------------------------------------------- /src/Composer/Installers/PiwikInstaller.php: -------------------------------------------------------------------------------- 1 | */ 13 | protected $locations = array( 14 | 'plugin' => 'plugins/{$name}/', 15 | ); 16 | 17 | /** 18 | * Format package name to CamelCase 19 | */ 20 | public function inflectPackageVars(array $vars): array 21 | { 22 | $vars['name'] = strtolower($this->pregReplace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name'])); 23 | $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); 24 | $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); 25 | 26 | return $vars; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Composer/Installers/PlentymarketsInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'plugin' => '{$name}/' 10 | ); 11 | 12 | /** 13 | * Remove hyphen, "plugin" and format to camelcase 14 | */ 15 | public function inflectPackageVars(array $vars): array 16 | { 17 | $nameBits = explode("-", $vars['name']); 18 | foreach ($nameBits as $key => $name) { 19 | $nameBits[$key] = ucfirst($name); 20 | if (strcasecmp($name, "Plugin") == 0) { 21 | unset($nameBits[$key]); 22 | } 23 | } 24 | $vars['name'] = implode('', $nameBits); 25 | 26 | return $vars; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Composer/Installers/Plugin.php: -------------------------------------------------------------------------------- 1 | installer = new Installer($io, $composer); 17 | $composer->getInstallationManager()->addInstaller($this->installer); 18 | } 19 | 20 | public function deactivate(Composer $composer, IOInterface $io): void 21 | { 22 | $composer->getInstallationManager()->removeInstaller($this->installer); 23 | } 24 | 25 | public function uninstall(Composer $composer, IOInterface $io): void 26 | { 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Composer/Installers/PortoInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'container' => 'app/Containers/{$name}/', 10 | ); 11 | } 12 | -------------------------------------------------------------------------------- /src/Composer/Installers/PrestashopInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'module' => 'modules/{$name}/', 10 | 'theme' => 'themes/{$name}/', 11 | ); 12 | } 13 | -------------------------------------------------------------------------------- /src/Composer/Installers/ProcessWireInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'module' => 'site/modules/{$name}/', 10 | ); 11 | 12 | /** 13 | * Format package name to CamelCase 14 | */ 15 | public function inflectPackageVars(array $vars): array 16 | { 17 | $vars['name'] = strtolower($this->pregReplace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name'])); 18 | $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); 19 | $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); 20 | 21 | return $vars; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Composer/Installers/PuppetInstaller.php: -------------------------------------------------------------------------------- 1 | */ 9 | protected $locations = array( 10 | 'module' => 'modules/{$name}/', 11 | ); 12 | } 13 | -------------------------------------------------------------------------------- /src/Composer/Installers/PxcmsInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'module' => 'app/Modules/{$name}/', 10 | 'theme' => 'themes/{$name}/', 11 | ); 12 | 13 | /** 14 | * Format package name. 15 | */ 16 | public function inflectPackageVars(array $vars): array 17 | { 18 | if ($vars['type'] === 'pxcms-module') { 19 | return $this->inflectModuleVars($vars); 20 | } 21 | 22 | if ($vars['type'] === 'pxcms-theme') { 23 | return $this->inflectThemeVars($vars); 24 | } 25 | 26 | return $vars; 27 | } 28 | 29 | /** 30 | * For package type pxcms-module, cut off a trailing '-plugin' if present. 31 | * 32 | * @param array $vars 33 | * @return array 34 | */ 35 | protected function inflectModuleVars(array $vars): array 36 | { 37 | $vars['name'] = str_replace('pxcms-', '', $vars['name']); // strip out pxcms- just incase (legacy) 38 | $vars['name'] = str_replace('module-', '', $vars['name']); // strip out module- 39 | $vars['name'] = $this->pregReplace('/-module$/', '', $vars['name']); // strip out -module 40 | $vars['name'] = str_replace('-', '_', $vars['name']); // make -'s be _'s 41 | $vars['name'] = ucwords($vars['name']); // make module name camelcased 42 | 43 | return $vars; 44 | } 45 | 46 | /** 47 | * For package type pxcms-module, cut off a trailing '-plugin' if present. 48 | * 49 | * @param array $vars 50 | * @return array 51 | */ 52 | protected function inflectThemeVars(array $vars): array 53 | { 54 | $vars['name'] = str_replace('pxcms-', '', $vars['name']); // strip out pxcms- just incase (legacy) 55 | $vars['name'] = str_replace('theme-', '', $vars['name']); // strip out theme- 56 | $vars['name'] = $this->pregReplace('/-theme$/', '', $vars['name']); // strip out -theme 57 | $vars['name'] = str_replace('-', '_', $vars['name']); // make -'s be _'s 58 | $vars['name'] = ucwords($vars['name']); // make module name camelcased 59 | 60 | return $vars; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/Composer/Installers/RadPHPInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'bundle' => 'src/{$name}/' 10 | ); 11 | 12 | /** 13 | * Format package name to CamelCase 14 | */ 15 | public function inflectPackageVars(array $vars): array 16 | { 17 | $nameParts = explode('/', $vars['name']); 18 | foreach ($nameParts as &$value) { 19 | $value = strtolower($this->pregReplace('/(?<=\\w)([A-Z])/', '_\\1', $value)); 20 | $value = str_replace(array('-', '_'), ' ', $value); 21 | $value = str_replace(' ', '', ucwords($value)); 22 | } 23 | $vars['name'] = implode('/', $nameParts); 24 | return $vars; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Composer/Installers/ReIndexInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'theme' => 'themes/{$name}/', 10 | 'plugin' => 'plugins/{$name}/' 11 | ); 12 | } 13 | -------------------------------------------------------------------------------- /src/Composer/Installers/Redaxo5Installer.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'addon' => 'redaxo/src/addons/{$name}/', 10 | 'bestyle-plugin' => 'redaxo/src/addons/be_style/plugins/{$name}/' 11 | ); 12 | } 13 | -------------------------------------------------------------------------------- /src/Composer/Installers/RedaxoInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'addon' => 'redaxo/include/addons/{$name}/', 10 | 'bestyle-plugin' => 'redaxo/include/addons/be_style/plugins/{$name}/' 11 | ); 12 | } 13 | -------------------------------------------------------------------------------- /src/Composer/Installers/RoundcubeInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'plugin' => 'plugins/{$name}/', 10 | ); 11 | 12 | /** 13 | * Lowercase name and changes the name to a underscores 14 | */ 15 | public function inflectPackageVars(array $vars): array 16 | { 17 | $vars['name'] = strtolower(str_replace('-', '_', $vars['name'])); 18 | 19 | return $vars; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Composer/Installers/SMFInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'module' => 'Sources/{$name}/', 10 | 'theme' => 'Themes/{$name}/', 11 | ); 12 | } 13 | -------------------------------------------------------------------------------- /src/Composer/Installers/ShopwareInstaller.php: -------------------------------------------------------------------------------- 1 | */ 12 | protected $locations = array( 13 | 'backend-plugin' => 'engine/Shopware/Plugins/Local/Backend/{$name}/', 14 | 'core-plugin' => 'engine/Shopware/Plugins/Local/Core/{$name}/', 15 | 'frontend-plugin' => 'engine/Shopware/Plugins/Local/Frontend/{$name}/', 16 | 'theme' => 'templates/{$name}/', 17 | 'plugin' => 'custom/plugins/{$name}/', 18 | 'frontend-theme' => 'themes/Frontend/{$name}/', 19 | ); 20 | 21 | /** 22 | * Transforms the names 23 | */ 24 | public function inflectPackageVars(array $vars): array 25 | { 26 | if ($vars['type'] === 'shopware-theme') { 27 | return $this->correctThemeName($vars); 28 | } 29 | 30 | return $this->correctPluginName($vars); 31 | } 32 | 33 | /** 34 | * Changes the name to a camelcased combination of vendor and name 35 | * 36 | * @param array $vars 37 | * @return array 38 | */ 39 | private function correctPluginName(array $vars): array 40 | { 41 | $camelCasedName = preg_replace_callback('/(-[a-z])/', function ($matches) { 42 | return strtoupper($matches[0][1]); 43 | }, $vars['name']); 44 | 45 | if (null === $camelCasedName) { 46 | throw new \RuntimeException('Failed to run preg_replace_callback: '.preg_last_error()); 47 | } 48 | 49 | $vars['name'] = ucfirst($vars['vendor']) . ucfirst($camelCasedName); 50 | 51 | return $vars; 52 | } 53 | 54 | /** 55 | * Changes the name to a underscore separated name 56 | * 57 | * @param array $vars 58 | * @return array 59 | */ 60 | private function correctThemeName(array $vars): array 61 | { 62 | $vars['name'] = str_replace('-', '_', $vars['name']); 63 | 64 | return $vars; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Composer/Installers/SilverStripeInstaller.php: -------------------------------------------------------------------------------- 1 | */ 10 | protected $locations = array( 11 | 'module' => '{$name}/', 12 | 'theme' => 'themes/{$name}/', 13 | ); 14 | 15 | /** 16 | * Return the install path based on package type. 17 | * 18 | * Relies on built-in BaseInstaller behaviour with one exception: silverstripe/framework 19 | * must be installed to 'sapphire' and not 'framework' if the version is <3.0.0 20 | */ 21 | public function getInstallPath(PackageInterface $package, string $frameworkType = ''): string 22 | { 23 | if ( 24 | $package->getName() == 'silverstripe/framework' 25 | && preg_match('/^\d+\.\d+\.\d+/', $package->getVersion()) 26 | && version_compare($package->getVersion(), '2.999.999') < 0 27 | ) { 28 | return $this->templatePath($this->locations['module'], array('name' => 'sapphire')); 29 | } 30 | 31 | return parent::getInstallPath($package, $frameworkType); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Composer/Installers/SiteDirectInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'module' => 'modules/{$vendor}/{$name}/', 10 | 'plugin' => 'plugins/{$vendor}/{$name}/' 11 | ); 12 | 13 | /** 14 | * @param array $vars 15 | * @return array 16 | */ 17 | public function inflectPackageVars(array $vars): array 18 | { 19 | return $this->parseVars($vars); 20 | } 21 | 22 | /** 23 | * @param array $vars 24 | * @return array 25 | */ 26 | protected function parseVars(array $vars): array 27 | { 28 | $vars['vendor'] = strtolower($vars['vendor']) == 'sitedirect' ? 'SiteDirect' : $vars['vendor']; 29 | $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); 30 | $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); 31 | 32 | return $vars; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Composer/Installers/StarbugInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'module' => 'modules/{$name}/', 10 | 'theme' => 'themes/{$name}/', 11 | 'custom-module' => 'app/modules/{$name}/', 12 | 'custom-theme' => 'app/themes/{$name}/' 13 | ); 14 | } 15 | -------------------------------------------------------------------------------- /src/Composer/Installers/SyDESInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'module' => 'app/modules/{$name}/', 10 | 'theme' => 'themes/{$name}/', 11 | ); 12 | 13 | /** 14 | * Format module name. 15 | * 16 | * Strip `sydes-` prefix and a trailing '-theme' or '-module' from package name if present. 17 | */ 18 | public function inflectPackageVars(array $vars): array 19 | { 20 | if ($vars['type'] == 'sydes-module') { 21 | return $this->inflectModuleVars($vars); 22 | } 23 | 24 | if ($vars['type'] === 'sydes-theme') { 25 | return $this->inflectThemeVars($vars); 26 | } 27 | 28 | return $vars; 29 | } 30 | 31 | /** 32 | * @param array $vars 33 | * @return array 34 | */ 35 | public function inflectModuleVars(array $vars): array 36 | { 37 | $vars['name'] = $this->pregReplace('/(^sydes-|-module$)/i', '', $vars['name']); 38 | $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); 39 | $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); 40 | 41 | return $vars; 42 | } 43 | 44 | /** 45 | * @param array $vars 46 | * @return array 47 | */ 48 | protected function inflectThemeVars(array $vars): array 49 | { 50 | $vars['name'] = $this->pregReplace('/(^sydes-|-theme$)/', '', $vars['name']); 51 | $vars['name'] = strtolower($vars['name']); 52 | 53 | return $vars; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/Composer/Installers/SyliusInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'theme' => 'themes/{$name}/', 10 | ); 11 | } 12 | -------------------------------------------------------------------------------- /src/Composer/Installers/TaoInstaller.php: -------------------------------------------------------------------------------- 1 | */ 13 | protected $locations = array( 14 | 'extension' => '{$name}' 15 | ); 16 | 17 | public function inflectPackageVars(array $vars): array 18 | { 19 | $extra = $this->package->getExtra(); 20 | 21 | if (array_key_exists(self::EXTRA_TAO_EXTENSION_NAME, $extra)) { 22 | $vars['name'] = $extra[self::EXTRA_TAO_EXTENSION_NAME]; 23 | return $vars; 24 | } 25 | 26 | $vars['name'] = str_replace('extension-', '', $vars['name']); 27 | $vars['name'] = str_replace('-', ' ', $vars['name']); 28 | $vars['name'] = lcfirst(str_replace(' ', '', ucwords($vars['name']))); 29 | 30 | return $vars; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Composer/Installers/TastyIgniterInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = [ 9 | 'module' => 'app/{$name}/', 10 | 'extension' => 'extensions/{$vendor}/{$name}/', 11 | 'theme' => 'themes/{$name}/', 12 | ]; 13 | 14 | /** 15 | * Format package name. 16 | * 17 | * Cut off leading 'ti-ext-' or 'ti-theme-' if present. 18 | * Strip vendor name of characters that is not alphanumeric or an underscore 19 | * 20 | */ 21 | public function inflectPackageVars(array $vars): array 22 | { 23 | $extra = $this->package->getExtra(); 24 | 25 | if ($vars['type'] === 'tastyigniter-module') { 26 | return $this->inflectModuleVars($vars); 27 | } 28 | 29 | if ($vars['type'] === 'tastyigniter-extension') { 30 | return $this->inflectExtensionVars($vars, $extra); 31 | } 32 | 33 | if ($vars['type'] === 'tastyigniter-theme') { 34 | return $this->inflectThemeVars($vars, $extra); 35 | } 36 | 37 | return $vars; 38 | } 39 | 40 | /** 41 | * @param array $vars 42 | * @return array 43 | */ 44 | protected function inflectModuleVars(array $vars): array 45 | { 46 | $vars['name'] = $this->pregReplace('/^ti-module-/', '', $vars['name']); 47 | 48 | return $vars; 49 | } 50 | 51 | /** 52 | * @param array $vars 53 | * @param array $extra 54 | * @return array 55 | */ 56 | protected function inflectExtensionVars(array $vars, array $extra): array 57 | { 58 | if (!empty($extra['tastyigniter-extension']['code'])) { 59 | $parts = explode('.', $extra['tastyigniter-extension']['code']); 60 | $vars['vendor'] = (string)$parts[0]; 61 | $vars['name'] = (string)($parts[1] ?? ''); 62 | } 63 | 64 | $vars['vendor'] = $this->pregReplace('/[^a-z0-9_]/i', '', $vars['vendor']); 65 | $vars['name'] = $this->pregReplace('/^ti-ext-/', '', $vars['name']); 66 | 67 | return $vars; 68 | } 69 | 70 | /** 71 | * @param array $vars 72 | * @param array $extra 73 | * @return array 74 | */ 75 | protected function inflectThemeVars(array $vars, array $extra): array 76 | { 77 | if (!empty($extra['tastyigniter-theme']['code'])) { 78 | $vars['name'] = $extra['tastyigniter-theme']['code']; 79 | } 80 | 81 | $vars['name'] = $this->pregReplace('/^ti-theme-/', '', $vars['name']); 82 | 83 | return $vars; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/Composer/Installers/TheliaInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'module' => 'local/modules/{$name}/', 10 | 'frontoffice-template' => 'templates/frontOffice/{$name}/', 11 | 'backoffice-template' => 'templates/backOffice/{$name}/', 12 | 'email-template' => 'templates/email/{$name}/', 13 | ); 14 | } 15 | -------------------------------------------------------------------------------- /src/Composer/Installers/TuskInstaller.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | class TuskInstaller extends BaseInstaller 10 | { 11 | /** @var array */ 12 | protected $locations = array( 13 | 'task' => '.tusk/tasks/{$name}/', 14 | 'command' => '.tusk/commands/{$name}/', 15 | 'asset' => 'assets/tusk/{$name}/', 16 | ); 17 | } 18 | -------------------------------------------------------------------------------- /src/Composer/Installers/UserFrostingInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'sprinkle' => 'app/sprinkles/{$name}/', 10 | ); 11 | } 12 | -------------------------------------------------------------------------------- /src/Composer/Installers/VanillaInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'plugin' => 'plugins/{$name}/', 10 | 'theme' => 'themes/{$name}/', 11 | ); 12 | } 13 | -------------------------------------------------------------------------------- /src/Composer/Installers/VgmcpInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'bundle' => 'src/{$vendor}/{$name}/', 10 | 'theme' => 'themes/{$name}/' 11 | ); 12 | 13 | /** 14 | * Format package name. 15 | * 16 | * For package type vgmcp-bundle, cut off a trailing '-bundle' if present. 17 | * 18 | * For package type vgmcp-theme, cut off a trailing '-theme' if present. 19 | * 20 | */ 21 | public function inflectPackageVars(array $vars): array 22 | { 23 | if ($vars['type'] === 'vgmcp-bundle') { 24 | return $this->inflectPluginVars($vars); 25 | } 26 | 27 | if ($vars['type'] === 'vgmcp-theme') { 28 | return $this->inflectThemeVars($vars); 29 | } 30 | 31 | return $vars; 32 | } 33 | 34 | /** 35 | * @param array $vars 36 | * @return array 37 | */ 38 | protected function inflectPluginVars(array $vars): array 39 | { 40 | $vars['name'] = $this->pregReplace('/-bundle$/', '', $vars['name']); 41 | $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); 42 | $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); 43 | 44 | return $vars; 45 | } 46 | 47 | /** 48 | * @param array $vars 49 | * @return array 50 | */ 51 | protected function inflectThemeVars(array $vars): array 52 | { 53 | $vars['name'] = $this->pregReplace('/-theme$/', '', $vars['name']); 54 | $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); 55 | $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); 56 | 57 | return $vars; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/Composer/Installers/WHMCSInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'addons' => 'modules/addons/{$vendor}_{$name}/', 10 | 'fraud' => 'modules/fraud/{$vendor}_{$name}/', 11 | 'gateways' => 'modules/gateways/{$vendor}_{$name}/', 12 | 'notifications' => 'modules/notifications/{$vendor}_{$name}/', 13 | 'registrars' => 'modules/registrars/{$vendor}_{$name}/', 14 | 'reports' => 'modules/reports/{$vendor}_{$name}/', 15 | 'security' => 'modules/security/{$vendor}_{$name}/', 16 | 'servers' => 'modules/servers/{$vendor}_{$name}/', 17 | 'social' => 'modules/social/{$vendor}_{$name}/', 18 | 'support' => 'modules/support/{$vendor}_{$name}/', 19 | 'templates' => 'templates/{$vendor}_{$name}/', 20 | 'includes' => 'includes/{$vendor}_{$name}/' 21 | ); 22 | } 23 | -------------------------------------------------------------------------------- /src/Composer/Installers/WinterInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'module' => 'modules/{$name}/', 10 | 'plugin' => 'plugins/{$vendor}/{$name}/', 11 | 'theme' => 'themes/{$name}/' 12 | ); 13 | 14 | /** 15 | * Format package name. 16 | * 17 | * For package type winter-plugin, cut off a trailing '-plugin' if present. 18 | * 19 | * For package type winter-theme, cut off a trailing '-theme' if present. 20 | */ 21 | public function inflectPackageVars(array $vars): array 22 | { 23 | if ($vars['type'] === 'winter-module') { 24 | return $this->inflectModuleVars($vars); 25 | } 26 | 27 | if ($vars['type'] === 'winter-plugin') { 28 | return $this->inflectPluginVars($vars); 29 | } 30 | 31 | if ($vars['type'] === 'winter-theme') { 32 | return $this->inflectThemeVars($vars); 33 | } 34 | 35 | return $vars; 36 | } 37 | 38 | /** 39 | * @param array $vars 40 | * @return array 41 | */ 42 | protected function inflectModuleVars(array $vars): array 43 | { 44 | $vars['name'] = $this->pregReplace('/^wn-|-module$/', '', $vars['name']); 45 | 46 | return $vars; 47 | } 48 | 49 | /** 50 | * @param array $vars 51 | * @return array 52 | */ 53 | protected function inflectPluginVars(array $vars): array 54 | { 55 | $vars['name'] = $this->pregReplace('/^wn-|-plugin$/', '', $vars['name']); 56 | $vars['vendor'] = $this->pregReplace('/[^a-z0-9_]/i', '', $vars['vendor']); 57 | 58 | return $vars; 59 | } 60 | 61 | /** 62 | * @param array $vars 63 | * @return array 64 | */ 65 | protected function inflectThemeVars(array $vars): array 66 | { 67 | $vars['name'] = $this->pregReplace('/^wn-|-theme$/', '', $vars['name']); 68 | 69 | return $vars; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/Composer/Installers/WolfCMSInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'plugin' => 'wolf/plugins/{$name}/', 10 | ); 11 | } 12 | -------------------------------------------------------------------------------- /src/Composer/Installers/WordPressInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'plugin' => 'wp-content/plugins/{$name}/', 10 | 'theme' => 'wp-content/themes/{$name}/', 11 | 'muplugin' => 'wp-content/mu-plugins/{$name}/', 12 | 'dropin' => 'wp-content/{$name}/', 13 | ); 14 | } 15 | -------------------------------------------------------------------------------- /src/Composer/Installers/YawikInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'module' => 'module/{$name}/', 10 | ); 11 | 12 | /** 13 | * Format package name to CamelCase 14 | */ 15 | public function inflectPackageVars(array $vars): array 16 | { 17 | $vars['name'] = strtolower($this->pregReplace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name'])); 18 | $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); 19 | $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); 20 | 21 | return $vars; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Composer/Installers/ZendInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'library' => 'library/{$name}/', 10 | 'extra' => 'extras/library/{$name}/', 11 | 'module' => 'module/{$name}/', 12 | ); 13 | } 14 | -------------------------------------------------------------------------------- /src/Composer/Installers/ZikulaInstaller.php: -------------------------------------------------------------------------------- 1 | */ 8 | protected $locations = array( 9 | 'module' => 'modules/{$vendor}-{$name}/', 10 | 'theme' => 'themes/{$vendor}-{$name}/' 11 | ); 12 | } 13 | -------------------------------------------------------------------------------- /src/bootstrap.php: -------------------------------------------------------------------------------- 1 |