AglInstaller.php
4 years ago
AimeosInstaller.php
4 years ago
AnnotateCmsInstaller.php
4 years ago
AsgardInstaller.php
4 years ago
AttogramInstaller.php
4 years ago
BaseInstaller.php
4 years ago
BitrixInstaller.php
4 years ago
BonefishInstaller.php
4 years ago
CakePHPInstaller.php
4 years ago
ChefInstaller.php
4 years ago
CiviCrmInstaller.php
4 years ago
ClanCatsFrameworkInstaller.php
4 years ago
CockpitInstaller.php
4 years ago
CodeIgniterInstaller.php
4 years ago
Concrete5Installer.php
4 years ago
CraftInstaller.php
4 years ago
CroogoInstaller.php
4 years ago
DecibelInstaller.php
4 years ago
DframeInstaller.php
4 years ago
DokuWikiInstaller.php
4 years ago
DolibarrInstaller.php
4 years ago
DrupalInstaller.php
4 years ago
ElggInstaller.php
4 years ago
EliasisInstaller.php
4 years ago
ExpressionEngineInstaller.php
4 years ago
EzPlatformInstaller.php
4 years ago
FuelInstaller.php
4 years ago
FuelphpInstaller.php
4 years ago
GravInstaller.php
4 years ago
HuradInstaller.php
4 years ago
ImageCMSInstaller.php
4 years ago
Installer.php
4 years ago
ItopInstaller.php
4 years ago
JoomlaInstaller.php
4 years ago
KanboardInstaller.php
4 years ago
KirbyInstaller.php
4 years ago
KnownInstaller.php
4 years ago
KodiCMSInstaller.php
4 years ago
KohanaInstaller.php
4 years ago
LanManagementSystemInstaller.php
4 years ago
LaravelInstaller.php
4 years ago
LavaLiteInstaller.php
4 years ago
LithiumInstaller.php
4 years ago
MODULEWorkInstaller.php
4 years ago
MODXEvoInstaller.php
4 years ago
MagentoInstaller.php
4 years ago
MajimaInstaller.php
4 years ago
MakoInstaller.php
4 years ago
MantisBTInstaller.php
4 years ago
MauticInstaller.php
4 years ago
MayaInstaller.php
4 years ago
MediaWikiInstaller.php
4 years ago
MiaoxingInstaller.php
4 years ago
MicroweberInstaller.php
4 years ago
ModxInstaller.php
4 years ago
MoodleInstaller.php
4 years ago
OctoberInstaller.php
4 years ago
OntoWikiInstaller.php
4 years ago
OsclassInstaller.php
4 years ago
OxidInstaller.php
4 years ago
PPIInstaller.php
4 years ago
PantheonInstaller.php
4 years ago
PhiftyInstaller.php
4 years ago
PhpBBInstaller.php
4 years ago
PimcoreInstaller.php
4 years ago
PiwikInstaller.php
4 years ago
PlentymarketsInstaller.php
4 years ago
Plugin.php
4 years ago
PortoInstaller.php
4 years ago
PrestashopInstaller.php
4 years ago
ProcessWireInstaller.php
4 years ago
PuppetInstaller.php
4 years ago
PxcmsInstaller.php
4 years ago
RadPHPInstaller.php
4 years ago
ReIndexInstaller.php
4 years ago
Redaxo5Installer.php
4 years ago
RedaxoInstaller.php
4 years ago
RoundcubeInstaller.php
4 years ago
SMFInstaller.php
4 years ago
ShopwareInstaller.php
4 years ago
SilverStripeInstaller.php
4 years ago
SiteDirectInstaller.php
4 years ago
StarbugInstaller.php
4 years ago
SyDESInstaller.php
4 years ago
SyliusInstaller.php
4 years ago
Symfony1Installer.php
4 years ago
TYPO3CmsInstaller.php
4 years ago
TYPO3FlowInstaller.php
4 years ago
TaoInstaller.php
4 years ago
TastyIgniterInstaller.php
4 years ago
TheliaInstaller.php
4 years ago
TuskInstaller.php
4 years ago
UserFrostingInstaller.php
4 years ago
VanillaInstaller.php
4 years ago
VgmcpInstaller.php
4 years ago
WHMCSInstaller.php
4 years ago
WinterInstaller.php
4 years ago
WolfCMSInstaller.php
4 years ago
WordPressInstaller.php
4 years ago
YawikInstaller.php
4 years ago
ZendInstaller.php
4 years ago
ZikulaInstaller.php
4 years ago
BitrixInstaller.php
127 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Composer\Installers; |
| 4 | |
| 5 | use Composer\Util\Filesystem; |
| 6 | |
| 7 | /** |
| 8 | * Installer for Bitrix Framework. Supported types of extensions: |
| 9 | * - `bitrix-d7-module` — copy the module to directory `bitrix/modules/<vendor>.<name>`. |
| 10 | * - `bitrix-d7-component` — copy the component to directory `bitrix/components/<vendor>/<name>`. |
| 11 | * - `bitrix-d7-template` — copy the template to directory `bitrix/templates/<vendor>_<name>`. |
| 12 | * |
| 13 | * You can set custom path to directory with Bitrix kernel in `composer.json`: |
| 14 | * |
| 15 | * ```json |
| 16 | * { |
| 17 | * "extra": { |
| 18 | * "bitrix-dir": "s1/bitrix" |
| 19 | * } |
| 20 | * } |
| 21 | * ``` |
| 22 | * |
| 23 | * @author Nik Samokhvalov <nik@samokhvalov.info> |
| 24 | * @author Denis Kulichkin <onexhovia@gmail.com> |
| 25 | */ |
| 26 | class BitrixInstaller extends BaseInstaller |
| 27 | { |
| 28 | protected $locations = array( |
| 29 | 'module' => '{$bitrix_dir}/modules/{$name}/', // deprecated, remove on the major release (Backward compatibility will be broken) |
| 30 | 'component' => '{$bitrix_dir}/components/{$name}/', // deprecated, remove on the major release (Backward compatibility will be broken) |
| 31 | 'theme' => '{$bitrix_dir}/templates/{$name}/', // deprecated, remove on the major release (Backward compatibility will be broken) |
| 32 | 'd7-module' => '{$bitrix_dir}/modules/{$vendor}.{$name}/', |
| 33 | 'd7-component' => '{$bitrix_dir}/components/{$vendor}/{$name}/', |
| 34 | 'd7-template' => '{$bitrix_dir}/templates/{$vendor}_{$name}/', |
| 35 | ); |
| 36 | |
| 37 | /** |
| 38 | * @var array Storage for informations about duplicates at all the time of installation packages. |
| 39 | */ |
| 40 | private static $checkedDuplicates = array(); |
| 41 | |
| 42 | /** |
| 43 | * {@inheritdoc} |
| 44 | */ |
| 45 | public function inflectPackageVars($vars) |
| 46 | { |
| 47 | if ($this->composer->getPackage()) { |
| 48 | $extra = $this->composer->getPackage()->getExtra(); |
| 49 | |
| 50 | if (isset($extra['bitrix-dir'])) { |
| 51 | $vars['bitrix_dir'] = $extra['bitrix-dir']; |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | if (!isset($vars['bitrix_dir'])) { |
| 56 | $vars['bitrix_dir'] = 'bitrix'; |
| 57 | } |
| 58 | |
| 59 | return parent::inflectPackageVars($vars); |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * {@inheritdoc} |
| 64 | */ |
| 65 | protected function templatePath($path, array $vars = array()) |
| 66 | { |
| 67 | $templatePath = parent::templatePath($path, $vars); |
| 68 | $this->checkDuplicates($templatePath, $vars); |
| 69 | |
| 70 | return $templatePath; |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * Duplicates search packages. |
| 75 | * |
| 76 | * @param string $path |
| 77 | * @param array $vars |
| 78 | */ |
| 79 | protected function checkDuplicates($path, array $vars = array()) |
| 80 | { |
| 81 | $packageType = substr($vars['type'], strlen('bitrix') + 1); |
| 82 | $localDir = explode('/', $vars['bitrix_dir']); |
| 83 | array_pop($localDir); |
| 84 | $localDir[] = 'local'; |
| 85 | $localDir = implode('/', $localDir); |
| 86 | |
| 87 | $oldPath = str_replace( |
| 88 | array('{$bitrix_dir}', '{$name}'), |
| 89 | array($localDir, $vars['name']), |
| 90 | $this->locations[$packageType] |
| 91 | ); |
| 92 | |
| 93 | if (in_array($oldPath, static::$checkedDuplicates)) { |
| 94 | return; |
| 95 | } |
| 96 | |
| 97 | if ($oldPath !== $path && file_exists($oldPath) && $this->io && $this->io->isInteractive()) { |
| 98 | |
| 99 | $this->io->writeError(' <error>Duplication of packages:</error>'); |
| 100 | $this->io->writeError(' <info>Package ' . $oldPath . ' will be called instead package ' . $path . '</info>'); |
| 101 | |
| 102 | while (true) { |
| 103 | switch ($this->io->ask(' <info>Delete ' . $oldPath . ' [y,n,?]?</info> ', '?')) { |
| 104 | case 'y': |
| 105 | $fs = new Filesystem(); |
| 106 | $fs->removeDirectory($oldPath); |
| 107 | break 2; |
| 108 | |
| 109 | case 'n': |
| 110 | break 2; |
| 111 | |
| 112 | case '?': |
| 113 | default: |
| 114 | $this->io->writeError(array( |
| 115 | ' y - delete package ' . $oldPath . ' and to continue with the installation', |
| 116 | ' n - don\'t delete and to continue with the installation', |
| 117 | )); |
| 118 | $this->io->writeError(' ? - print help'); |
| 119 | break; |
| 120 | } |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | static::$checkedDuplicates[] = $oldPath; |
| 125 | } |
| 126 | } |
| 127 |