From 8edb2d7ea4ca0fdc999c42509d954a127b55faeb Mon Sep 17 00:00:00 2001 From: Peter Ivanov Date: Tue, 9 Jul 2019 11:36:35 +0300 Subject: [PATCH 1/4] update MicroweberInstaller --- .../Installers/MicroweberInstaller.php | 55 +++++++++++-------- 1 file changed, 32 insertions(+), 23 deletions(-) diff --git a/src/Composer/Installers/MicroweberInstaller.php b/src/Composer/Installers/MicroweberInstaller.php index 4bbbec8c..98847eeb 100644 --- a/src/Composer/Installers/MicroweberInstaller.php +++ b/src/Composer/Installers/MicroweberInstaller.php @@ -4,12 +4,12 @@ class MicroweberInstaller extends BaseInstaller { protected $locations = array( - 'module' => 'userfiles/modules/{$name}/', - 'module-skin' => 'userfiles/modules/{$name}/templates/', - 'template' => 'userfiles/templates/{$name}/', - 'element' => 'userfiles/elements/{$name}/', - 'vendor' => 'vendor/{$name}/', - 'components' => 'components/{$name}/' + 'module' => 'userfiles/modules/{$install_item_dir}/', + 'module-skin' => 'userfiles/modules/{$install_item_dir}/templates/', + 'template' => 'userfiles/templates/{$install_item_dir}/', + 'element' => 'userfiles/elements/{$install_item_dir}/', + 'vendor' => 'vendor/{$install_item_dir}/', + 'components' => 'components/{$install_item_dir}/' ); /** @@ -22,6 +22,15 @@ class MicroweberInstaller extends BaseInstaller */ public function inflectPackageVars($vars) { + $vars['install_item_dir'] = $vars['name']; + if ($this->composer->getPackage()) { + $extra = $this->composer->getPackage()->getExtra(); + if (isset($extra['target-dir'])) { + $vars['install_item_dir'] = $extra['target-dir']; + return $vars; + } + } + if ($vars['type'] === 'microweber-template') { return $this->inflectTemplateVars($vars); } @@ -52,59 +61,59 @@ public function inflectPackageVars($vars) protected function inflectTemplateVars($vars) { - $vars['name'] = preg_replace('/-template$/', '', $vars['name']); - $vars['name'] = preg_replace('/template-$/', '', $vars['name']); + $vars['install_item_dir'] = preg_replace('/-template$/', '', $vars['name']); + $vars['install_item_dir'] = preg_replace('/template-$/', '', $vars['install_item_dir']); return $vars; } protected function inflectTemplatesVars($vars) { - $vars['name'] = preg_replace('/-templates$/', '', $vars['name']); - $vars['name'] = preg_replace('/templates-$/', '', $vars['name']); + $vars['install_item_dir'] = preg_replace('/-templates$/', '', $vars['name']); + $vars['install_item_dir'] = preg_replace('/templates-$/', '', $vars['install_item_dir']); return $vars; } protected function inflectCoreVars($vars) { - $vars['name'] = preg_replace('/-providers$/', '', $vars['name']); - $vars['name'] = preg_replace('/-provider$/', '', $vars['name']); - $vars['name'] = preg_replace('/-adapter$/', '', $vars['name']); + $vars['install_item_dir'] = preg_replace('/-providers$/', '', $vars['name']); + $vars['install_item_dir'] = preg_replace('/-provider$/', '', $vars['install_item_dir']); + $vars['install_item_dir'] = preg_replace('/-adapter$/', '', $vars['install_item_dir']); return $vars; } protected function inflectModuleVars($vars) { - $vars['name'] = preg_replace('/-module$/', '', $vars['name']); - $vars['name'] = preg_replace('/module-$/', '', $vars['name']); + $vars['install_item_dir'] = preg_replace('/-module$/', '', $vars['name']); + $vars['install_item_dir'] = preg_replace('/module-$/', '', $vars['install_item_dir']); return $vars; } protected function inflectModulesVars($vars) { - $vars['name'] = preg_replace('/-modules$/', '', $vars['name']); - $vars['name'] = preg_replace('/modules-$/', '', $vars['name']); + $vars['install_item_dir'] = preg_replace('/-modules$/', '', $vars['name']); + $vars['install_item_dir'] = preg_replace('/modules-$/', '', $vars['install_item_dir']); return $vars; } protected function inflectSkinVars($vars) { - $vars['name'] = preg_replace('/-skin$/', '', $vars['name']); - $vars['name'] = preg_replace('/skin-$/', '', $vars['name']); + $vars['install_item_dir'] = preg_replace('/-skin$/', '', $vars['name']); + $vars['install_item_dir'] = preg_replace('/skin-$/', '', $vars['install_item_dir']); return $vars; } protected function inflectElementVars($vars) { - $vars['name'] = preg_replace('/-elements$/', '', $vars['name']); - $vars['name'] = preg_replace('/elements-$/', '', $vars['name']); - $vars['name'] = preg_replace('/-element$/', '', $vars['name']); - $vars['name'] = preg_replace('/element-$/', '', $vars['name']); + $vars['install_item_dir'] = preg_replace('/-elements$/', '', $vars['name']); + $vars['install_item_dir'] = preg_replace('/elements-$/', '', $vars['install_item_dir']); + $vars['install_item_dir'] = preg_replace('/-element$/', '', $vars['install_item_dir']); + $vars['install_item_dir'] = preg_replace('/element-$/', '', $vars['install_item_dir']); return $vars; } From 42b317a9067d266aeb7ee08c0aeca1a93372b118 Mon Sep 17 00:00:00 2001 From: Peter Ivanov Date: Wed, 10 Jul 2019 11:01:37 +0300 Subject: [PATCH 2/4] update --- src/Composer/Installers/MicroweberInstaller.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Composer/Installers/MicroweberInstaller.php b/src/Composer/Installers/MicroweberInstaller.php index 98847eeb..b51905be 100644 --- a/src/Composer/Installers/MicroweberInstaller.php +++ b/src/Composer/Installers/MicroweberInstaller.php @@ -23,6 +23,9 @@ class MicroweberInstaller extends BaseInstaller public function inflectPackageVars($vars) { $vars['install_item_dir'] = $vars['name']; + if (isset($vars['target-dir'])) { + $vars['install_item_dir'] = $vars['target-dir']; + } if ($this->composer->getPackage()) { $extra = $this->composer->getPackage()->getExtra(); if (isset($extra['target-dir'])) { From 17799c538da1c3c51ac777d8f46dd6d888d7caf5 Mon Sep 17 00:00:00 2001 From: Peter Ivanov Date: Wed, 10 Jul 2019 17:58:55 +0300 Subject: [PATCH 3/4] update --- .../Installers/MicroweberInstaller.php | 26 +++++++------------ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/src/Composer/Installers/MicroweberInstaller.php b/src/Composer/Installers/MicroweberInstaller.php index b51905be..4e49d5c5 100644 --- a/src/Composer/Installers/MicroweberInstaller.php +++ b/src/Composer/Installers/MicroweberInstaller.php @@ -22,16 +22,10 @@ class MicroweberInstaller extends BaseInstaller */ public function inflectPackageVars($vars) { + $vars['install_item_dir'] = $vars['name']; - if (isset($vars['target-dir'])) { - $vars['install_item_dir'] = $vars['target-dir']; - } - if ($this->composer->getPackage()) { - $extra = $this->composer->getPackage()->getExtra(); - if (isset($extra['target-dir'])) { - $vars['install_item_dir'] = $extra['target-dir']; - return $vars; - } + if ($this->package->getTargetDir()) { + $vars['install_item_dir'] = $this->package->getTargetDir(); } if ($vars['type'] === 'microweber-template') { @@ -64,7 +58,7 @@ public function inflectPackageVars($vars) protected function inflectTemplateVars($vars) { - $vars['install_item_dir'] = preg_replace('/-template$/', '', $vars['name']); + $vars['install_item_dir'] = preg_replace('/-template$/', '', $vars['install_item_dir']); $vars['install_item_dir'] = preg_replace('/template-$/', '', $vars['install_item_dir']); return $vars; @@ -72,7 +66,7 @@ protected function inflectTemplateVars($vars) protected function inflectTemplatesVars($vars) { - $vars['install_item_dir'] = preg_replace('/-templates$/', '', $vars['name']); + $vars['install_item_dir'] = preg_replace('/-templates$/', '', $vars['install_item_dir']); $vars['install_item_dir'] = preg_replace('/templates-$/', '', $vars['install_item_dir']); return $vars; @@ -80,7 +74,7 @@ protected function inflectTemplatesVars($vars) protected function inflectCoreVars($vars) { - $vars['install_item_dir'] = preg_replace('/-providers$/', '', $vars['name']); + $vars['install_item_dir'] = preg_replace('/-providers$/', '', $vars['install_item_dir']); $vars['install_item_dir'] = preg_replace('/-provider$/', '', $vars['install_item_dir']); $vars['install_item_dir'] = preg_replace('/-adapter$/', '', $vars['install_item_dir']); @@ -89,7 +83,7 @@ protected function inflectCoreVars($vars) protected function inflectModuleVars($vars) { - $vars['install_item_dir'] = preg_replace('/-module$/', '', $vars['name']); + $vars['install_item_dir'] = preg_replace('/-module$/', '', $vars['install_item_dir']); $vars['install_item_dir'] = preg_replace('/module-$/', '', $vars['install_item_dir']); return $vars; @@ -97,7 +91,7 @@ protected function inflectModuleVars($vars) protected function inflectModulesVars($vars) { - $vars['install_item_dir'] = preg_replace('/-modules$/', '', $vars['name']); + $vars['install_item_dir'] = preg_replace('/-modules$/', '', $vars['install_item_dir']); $vars['install_item_dir'] = preg_replace('/modules-$/', '', $vars['install_item_dir']); return $vars; @@ -105,7 +99,7 @@ protected function inflectModulesVars($vars) protected function inflectSkinVars($vars) { - $vars['install_item_dir'] = preg_replace('/-skin$/', '', $vars['name']); + $vars['install_item_dir'] = preg_replace('/-skin$/', '', $vars['install_item_dir']); $vars['install_item_dir'] = preg_replace('/skin-$/', '', $vars['install_item_dir']); return $vars; @@ -113,7 +107,7 @@ protected function inflectSkinVars($vars) protected function inflectElementVars($vars) { - $vars['install_item_dir'] = preg_replace('/-elements$/', '', $vars['name']); + $vars['install_item_dir'] = preg_replace('/-elements$/', '', $vars['install_item_dir']); $vars['install_item_dir'] = preg_replace('/elements-$/', '', $vars['install_item_dir']); $vars['install_item_dir'] = preg_replace('/-element$/', '', $vars['install_item_dir']); $vars['install_item_dir'] = preg_replace('/element-$/', '', $vars['install_item_dir']); From d924c1bac31ecd9460a0c8a40570fd785dc2d1e3 Mon Sep 17 00:00:00 2001 From: Peter Ivanov Date: Wed, 10 Jul 2019 18:24:09 +0300 Subject: [PATCH 4/4] update --- .../Installers/MicroweberInstaller.php | 62 ++++++++++--------- 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/src/Composer/Installers/MicroweberInstaller.php b/src/Composer/Installers/MicroweberInstaller.php index 4e49d5c5..b7d97039 100644 --- a/src/Composer/Installers/MicroweberInstaller.php +++ b/src/Composer/Installers/MicroweberInstaller.php @@ -4,12 +4,12 @@ class MicroweberInstaller extends BaseInstaller { protected $locations = array( - 'module' => 'userfiles/modules/{$install_item_dir}/', + 'module' => 'userfiles/modules/{$install_item_dir}/', 'module-skin' => 'userfiles/modules/{$install_item_dir}/templates/', - 'template' => 'userfiles/templates/{$install_item_dir}/', - 'element' => 'userfiles/elements/{$install_item_dir}/', - 'vendor' => 'vendor/{$install_item_dir}/', - 'components' => 'components/{$install_item_dir}/' + 'template' => 'userfiles/templates/{$install_item_dir}/', + 'element' => 'userfiles/elements/{$install_item_dir}/', + 'vendor' => 'vendor/{$install_item_dir}/', + 'components' => 'components/{$install_item_dir}/' ); /** @@ -23,35 +23,37 @@ class MicroweberInstaller extends BaseInstaller public function inflectPackageVars($vars) { - $vars['install_item_dir'] = $vars['name']; + if ($this->package->getTargetDir()) { $vars['install_item_dir'] = $this->package->getTargetDir(); + } else { + $vars['install_item_dir'] = $vars['name']; + if ($vars['type'] === 'microweber-template') { + return $this->inflectTemplateVars($vars); + } + if ($vars['type'] === 'microweber-templates') { + return $this->inflectTemplatesVars($vars); + } + if ($vars['type'] === 'microweber-core') { + return $this->inflectCoreVars($vars); + } + if ($vars['type'] === 'microweber-adapter') { + return $this->inflectCoreVars($vars); + } + if ($vars['type'] === 'microweber-module') { + return $this->inflectModuleVars($vars); + } + if ($vars['type'] === 'microweber-modules') { + return $this->inflectModulesVars($vars); + } + if ($vars['type'] === 'microweber-skin') { + return $this->inflectSkinVars($vars); + } + if ($vars['type'] === 'microweber-element' or $vars['type'] === 'microweber-elements') { + return $this->inflectElementVars($vars); + } } - if ($vars['type'] === 'microweber-template') { - return $this->inflectTemplateVars($vars); - } - if ($vars['type'] === 'microweber-templates') { - return $this->inflectTemplatesVars($vars); - } - if ($vars['type'] === 'microweber-core') { - return $this->inflectCoreVars($vars); - } - if ($vars['type'] === 'microweber-adapter') { - return $this->inflectCoreVars($vars); - } - if ($vars['type'] === 'microweber-module') { - return $this->inflectModuleVars($vars); - } - if ($vars['type'] === 'microweber-modules') { - return $this->inflectModulesVars($vars); - } - if ($vars['type'] === 'microweber-skin') { - return $this->inflectSkinVars($vars); - } - if ($vars['type'] === 'microweber-element' or $vars['type'] === 'microweber-elements') { - return $this->inflectElementVars($vars); - } return $vars; }