PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / trunk
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF vtrunk
2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.9 2.2.8 trunk 1.10 1.3.3 1.3.4 1.3.5 1.3.5.1 1.3.5.2 1.3.6 1.3.6.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.5 All 103 releases
imagify / vendor / composer / installers / src / Composer / Installers / ShopwareInstaller.php

ShopwareInstaller.php in Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF trunk, at vendor/composer/installers/src/Composer/Installers/ShopwareInstaller.php

67 lines 1.9 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 /**
6 * Plugin/theme installer for shopware
7 * @author Benjamin Boit
8 */
9 class ShopwareInstaller extends BaseInstaller
10 {
11 /** @var array<string, string> */
12 protected $locations = array(
13 'backend-plugin' => 'engine/Shopware/Plugins/Local/Backend/{$name}/',
14 'core-plugin' => 'engine/Shopware/Plugins/Local/Core/{$name}/',
15 'frontend-plugin' => 'engine/Shopware/Plugins/Local/Frontend/{$name}/',
16 'theme' => 'templates/{$name}/',
17 'plugin' => 'custom/plugins/{$name}/',
18 'frontend-theme' => 'themes/Frontend/{$name}/',
19 );
20
21 /**
22 * Transforms the names
23 */
24 public function inflectPackageVars(array $vars): array
25 {
26 if ($vars['type'] === 'shopware-theme') {
27 return $this->correctThemeName($vars);
28 }
29
30 return $this->correctPluginName($vars);
31 }
32
33 /**
34 * Changes the name to a camelcased combination of vendor and name
35 *
36 * @param array<string, string> $vars
37 * @return array<string, string>
38 */
39 private function correctPluginName(array $vars): array
40 {
41 $camelCasedName = preg_replace_callback('/(-[a-z])/', function ($matches) {
42 return strtoupper($matches[0][1]);
43 }, $vars['name']);
44
45 if (null === $camelCasedName) {
46 throw new \RuntimeException('Failed to run preg_replace_callback: '.preg_last_error());
47 }
48
49 $vars['name'] = ucfirst($vars['vendor']) . ucfirst($camelCasedName);
50
51 return $vars;
52 }
53
54 /**
55 * Changes the name to a underscore separated name
56 *
57 * @param array<string, string> $vars
58 * @return array<string, string>
59 */
60 private function correctThemeName(array $vars): array
61 {
62 $vars['name'] = str_replace('-', '_', $vars['name']);
63
64 return $vars;
65 }
66 }
67