Blame view

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