ComposerInstallersBitrixInstaller

Installer for Bitrix Framework.

Defined (1)

The class is defined in the following location(s).

/vendor/composer/installers/src/Composer/Installers/BitrixInstaller.php  
  1. class BitrixInstaller extends BaseInstaller 
  2. protected $locations = array( 
  3. 'module' => '{$bitrix_dir}/modules/{$name}/', // deprecated, remove on the major release (Backward compatibility will be broken) 
  4. 'component' => '{$bitrix_dir}/components/{$name}/', // deprecated, remove on the major release (Backward compatibility will be broken) 
  5. 'theme' => '{$bitrix_dir}/templates/{$name}/', // deprecated, remove on the major release (Backward compatibility will be broken) 
  6. 'd7-module' => '{$bitrix_dir}/modules/{$vendor}.{$name}/',  
  7. 'd7-component' => '{$bitrix_dir}/components/{$vendor}/{$name}/',  
  8. 'd7-template' => '{$bitrix_dir}/templates/{$vendor}_{$name}/',  
  9. ); 
  10.  
  11. /** 
  12. * @var array Storage for informations about duplicates at all the time of installation packages. 
  13. */ 
  14. private static $checkedDuplicates = array(); 
  15.  
  16. /** 
  17. * {@inheritdoc} 
  18. */ 
  19. public function inflectPackageVars($vars) 
  20. if ($this->composer->getPackage()) { 
  21. $extra = $this->composer->getPackage()->getExtra(); 
  22.  
  23. if (isset($extra['bitrix-dir'])) { 
  24. $vars['bitrix_dir'] = $extra['bitrix-dir']; 
  25.  
  26. if (!isset($vars['bitrix_dir'])) { 
  27. $vars['bitrix_dir'] = 'bitrix'; 
  28.  
  29. return parent::inflectPackageVars($vars); 
  30.  
  31. /** 
  32. * {@inheritdoc} 
  33. */ 
  34. protected function templatePath($path, array $vars = array()) 
  35. $templatePath = parent::templatePath($path, $vars); 
  36. $this->checkDuplicates($templatePath, $vars); 
  37.  
  38. return $templatePath; 
  39.  
  40. /** 
  41. * Duplicates search packages. 
  42. * @param string $path 
  43. * @param array $vars 
  44. */ 
  45. protected function checkDuplicates($path, array $vars = array()) 
  46. $packageType = substr($vars['type'], strlen('bitrix') + 1); 
  47. $localDir = explode('/', $vars['bitrix_dir']); 
  48. array_pop($localDir); 
  49. $localDir[] = 'local'; 
  50. $localDir = implode('/', $localDir); 
  51.  
  52. $oldPath = str_replace( 
  53. array('{$bitrix_dir}', '{$name}'),  
  54. array($localDir, $vars['name']),  
  55. $this->locations[$packageType] 
  56. ); 
  57.  
  58. if (in_array($oldPath, static::$checkedDuplicates)) { 
  59. return; 
  60.  
  61. if ($oldPath !== $path && file_exists($oldPath) && $this->io && $this->io->isInteractive()) { 
  62.  
  63. $this->io->writeError(' <error>Duplication of packages:</error>'); 
  64. $this->io->writeError(' <info>Package ' . $oldPath . ' will be called instead package ' . $path . '</info>'); 
  65.  
  66. while (true) { 
  67. switch ($this->io->ask(' <info>Delete ' . $oldPath . ' [y, n, ?]?</info> ', '?')) { 
  68. case 'y': 
  69. $fs = new Filesystem(); 
  70. $fs->removeDirectory($oldPath); 
  71. break 2; 
  72.  
  73. case 'n': 
  74. break 2; 
  75.  
  76. case '?': 
  77. default: 
  78. $this->io->writeError(array( 
  79. ' y - delete package ' . $oldPath . ' and to continue with the installation',  
  80. ' n - don\'t delete and to continue with the installation',  
  81. )); 
  82. $this->io->writeError(' ? - print help'); 
  83. break; 
  84.  
  85. static::$checkedDuplicates[] = $oldPath;