PluginProbe
Code Snippets / 3.10.1
Code Snippets v3.10.1
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 3.0.0 All 65 releases
code-snippets / vendor / composer / installers / src / Composer / Installers / OxidInstaller.php

OxidInstaller.php in Code Snippets 3.10.1, at vendor/composer/installers/src/Composer/Installers/OxidInstaller.php

50 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Composer\Installers;
4
5 use Composer\Package\PackageInterface;
6
7 class OxidInstaller extends BaseInstaller
8 {
9 const VENDOR_PATTERN = '/^modules\/(?P<vendor>.+)\/.+/';
10
11 /** @var array<string, string> */
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