PluginProbe
Code Snippets / trunk
Code Snippets vtrunk
4.0.0-beta.3 4.0.0-beta.2 3.10.2 3.10.1 3.10.0 3.10.0-beta.2 3.10.0-beta.1 4.0.0-beta.1 3.9.6 trunk 2.10.0 2.10.1 2.12.0 2.12.1 2.13.0 2.13.1 2.13.2 2.13.3 2.14.0 2.14.1 2.14.2 2.14.3 2.14.4 2.14.5 2.14.6 All 66 releases
← 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 }