← All changes
|
vendor/composer/installers/src/Composer/Installers/OxidInstaller.php
+31
-41
3.0.0
→
trunk
View file →
| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | <?php |
| 2 | + | |
| 2 | 3 | namespace Composer\Installers; |
| 3 | 4 | |
| 4 | 5 | use Composer\Package\PackageInterface; |
| 5 | 6 | |
| @@ -4,10 +5,11 @@ | ||
| 4 | 5 | use Composer\Package\PackageInterface; |
| 5 | 6 | |
| 6 | 7 | class OxidInstaller extends BaseInstaller |
| 7 | 8 | { |
| 8 | - const VENDOR_PATTERN = '/^modules\/(?P<vendor>.+)\/.+/'; | |
| 9 | + const VENDOR_PATTERN = '/^modules\/(?P<vendor>.+)\/.+/'; | |
| 9 | 10 | |
| 11 | + /** @var array<string, string> */ | |
| 10 | 12 | protected $locations = array( |
| 11 | 13 | 'module' => 'modules/{$name}/', |
| 12 | 14 | 'theme' => 'application/views/{$name}/', |
| 13 | 15 | 'out' => 'out/{$name}/', |
| @@ -12,48 +14,36 @@ | ||
| 12 | 14 | 'theme' => 'application/views/{$name}/', |
| 13 | 15 | 'out' => 'out/{$name}/', |
| 14 | 16 | ); |
| 15 | 17 | |
| 16 | - /** | |
| 17 | - * getInstallPath | |
| 18 | - * | |
| 19 | - * @param PackageInterface $package | |
| 20 | - * @param string $frameworkType | |
| 21 | - * @return string | |
| 22 | - */ | |
| 23 | - public function getInstallPath(PackageInterface $package, $frameworkType = '') | |
| 24 | - { | |
| 25 | - $installPath = parent::getInstallPath($package, $frameworkType); | |
| 26 | - $type = $this->package->getType(); | |
| 27 | - if ($type === 'oxid-module') { | |
| 28 | - $this->prepareVendorDirectory($installPath); | |
| 29 | - } | |
| 30 | - return $installPath; | |
| 31 | - } | |
| 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 | + } | |
| 32 | 27 | |
| 33 | - /** | |
| 34 | - * prepareVendorDirectory | |
| 35 | - * | |
| 36 | - * Makes sure there is a vendormetadata.php file inside | |
| 37 | - * the vendor folder if there is a vendor folder. | |
| 38 | - * | |
| 39 | - * @param string $installPath | |
| 40 | - * @return void | |
| 41 | - */ | |
| 42 | - protected function prepareVendorDirectory($installPath) | |
| 43 | - { | |
| 44 | - $matches = ''; | |
| 45 | - $hasVendorDirectory = preg_match(self::VENDOR_PATTERN, $installPath, $matches); | |
| 46 | - if (!$hasVendorDirectory) { | |
| 47 | - return; | |
| 48 | - } | |
| 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 | + } | |
| 49 | 39 | |
| 50 | - $vendorDirectory = $matches['vendor']; | |
| 51 | - $vendorPath = getcwd() . '/modules/' . $vendorDirectory; | |
| 52 | - if (!file_exists($vendorPath)) { | |
| 53 | - mkdir($vendorPath, 0755, true); | |
| 54 | - } | |
| 40 | + $vendorDirectory = $matches['vendor']; | |
| 41 | + $vendorPath = getcwd() . '/modules/' . $vendorDirectory; | |
| 42 | + if (!file_exists($vendorPath)) { | |
| 43 | + mkdir($vendorPath, 0755, true); | |
| 44 | + } | |
| 55 | 45 | |
| 56 | - $vendorMetaDataPath = $vendorPath . '/vendormetadata.php'; | |
| 57 | - touch($vendorMetaDataPath); | |
| 58 | - } | |
| 46 | + $vendorMetaDataPath = $vendorPath . '/vendormetadata.php'; | |
| 47 | + touch($vendorMetaDataPath); | |
| 48 | + } | |
| 59 | 49 | } |