DokuWikiInstaller.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace Composer\Installers;
  3. class DokuWikiInstaller extends BaseInstaller
  4. {
  5. protected $locations = array(
  6. 'plugin' => 'lib/plugins/{$name}/',
  7. 'template' => 'lib/tpl/{$name}/',
  8. );
  9. /**
  10. * Format package name.
  11. *
  12. * For package type dokuwiki-plugin, cut off a trailing '-plugin',
  13. * or leading dokuwiki_ if present.
  14. *
  15. * For package type dokuwiki-template, cut off a trailing '-template' if present.
  16. *
  17. */
  18. public function inflectPackageVars($vars)
  19. {
  20. if ($vars['type'] === 'dokuwiki-plugin') {
  21. return $this->inflectPluginVars($vars);
  22. }
  23. if ($vars['type'] === 'dokuwiki-template') {
  24. return $this->inflectTemplateVars($vars);
  25. }
  26. return $vars;
  27. }
  28. protected function inflectPluginVars($vars)
  29. {
  30. $vars['name'] = preg_replace('/-plugin$/', '', $vars['name']);
  31. $vars['name'] = preg_replace('/^dokuwiki_?-?/', '', $vars['name']);
  32. return $vars;
  33. }
  34. protected function inflectTemplateVars($vars)
  35. {
  36. $vars['name'] = preg_replace('/-template$/', '', $vars['name']);
  37. $vars['name'] = preg_replace('/^dokuwiki_?-?/', '', $vars['name']);
  38. return $vars;
  39. }
  40. }