AsgardInstaller.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace Composer\Installers;
  3. class AsgardInstaller extends BaseInstaller
  4. {
  5. protected $locations = array(
  6. 'module' => 'Modules/{$name}/',
  7. 'theme' => 'Themes/{$name}/'
  8. );
  9. /**
  10. * Format package name.
  11. *
  12. * For package type asgard-module, cut off a trailing '-plugin' if present.
  13. *
  14. * For package type asgard-theme, cut off a trailing '-theme' if present.
  15. *
  16. */
  17. public function inflectPackageVars($vars)
  18. {
  19. if ($vars['type'] === 'asgard-module') {
  20. return $this->inflectPluginVars($vars);
  21. }
  22. if ($vars['type'] === 'asgard-theme') {
  23. return $this->inflectThemeVars($vars);
  24. }
  25. return $vars;
  26. }
  27. protected function inflectPluginVars($vars)
  28. {
  29. $vars['name'] = preg_replace('/-module$/', '', $vars['name']);
  30. $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']);
  31. $vars['name'] = str_replace(' ', '', ucwords($vars['name']));
  32. return $vars;
  33. }
  34. protected function inflectThemeVars($vars)
  35. {
  36. $vars['name'] = preg_replace('/-theme$/', '', $vars['name']);
  37. $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']);
  38. $vars['name'] = str_replace(' ', '', ucwords($vars['name']));
  39. return $vars;
  40. }
  41. }