2 namespace Composer\Installers;
4 use Composer\Package\PackageInterface;
6 class OxidInstaller extends BaseInstaller
8 const VENDOR_PATTERN = '/^modules\/(?P<vendor>.+)\/.+/';
10 protected $locations = array(
11 'module' => 'modules/{$name}/',
12 'theme' => 'application/views/{$name}/',
13 'out' => 'out/{$name}/',
19 * @param PackageInterface $package
20 * @param string $frameworkType
23 public function getInstallPath(PackageInterface $package, $frameworkType = '')
25 $installPath = parent::getInstallPath($package, $frameworkType);
26 $type = $this->package->getType();
27 if ($type === 'oxid-module') {
28 $this->prepareVendorDirectory($installPath);
34 * prepareVendorDirectory
36 * Makes sure there is a vendormetadata.php file inside
37 * the vendor folder if there is a vendor folder.
39 * @param string $installPath
42 protected function prepareVendorDirectory($installPath)
45 $hasVendorDirectory = preg_match(self::VENDOR_PATTERN, $installPath, $matches);
46 if (!$hasVendorDirectory) {
50 $vendorDirectory = $matches['vendor'];
51 $vendorPath = getcwd() . '/modules/' . $vendorDirectory;
52 if (!file_exists($vendorPath)) {
53 mkdir($vendorPath, 0755, true);
56 $vendorMetaDataPath = $vendorPath . '/vendormetadata.php';
57 touch($vendorMetaDataPath);