Mercurial > hg > isophonics-drupal-site
comparison vendor/composer/installers/src/Composer/Installers/OxidInstaller.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 namespace Composer\Installers; | |
3 | |
4 use Composer\Package\PackageInterface; | |
5 | |
6 class OxidInstaller extends BaseInstaller | |
7 { | |
8 const VENDOR_PATTERN = '/^modules\/(?P<vendor>.+)\/.+/'; | |
9 | |
10 protected $locations = array( | |
11 'module' => 'modules/{$name}/', | |
12 'theme' => 'application/views/{$name}/', | |
13 'out' => 'out/{$name}/', | |
14 ); | |
15 | |
16 /** | |
17 * getInstallPath | |
18 * | |
19 * @param PackageInterface $package | |
20 * @param string $frameworkType | |
21 * @return void | |
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 } | |
32 | |
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 } | |
49 | |
50 $vendorDirectory = $matches['vendor']; | |
51 $vendorPath = getcwd() . '/modules/' . $vendorDirectory; | |
52 if (!file_exists($vendorPath)) { | |
53 mkdir($vendorPath, 0755, true); | |
54 } | |
55 | |
56 $vendorMetaDataPath = $vendorPath . '/vendormetadata.php'; | |
57 touch($vendorMetaDataPath); | |
58 } | |
59 } |