Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. BitrixInstaller.php

function BitrixInstaller::checkDuplicates

Duplicates search packages.

Parameters

array<string, string> $vars:

1 call to BitrixInstaller::checkDuplicates()
BitrixInstaller::templatePath in vendor/composer/installers/src/Composer/Installers/BitrixInstaller.php
Replace vars in a path

File

vendor/composer/installers/src/Composer/Installers/BitrixInstaller.php, line 77

Class

BitrixInstaller
Installer for Bitrix Framework. Supported types of extensions:

Namespace

Composer\Installers

Code

protected function checkDuplicates(string $path, array $vars = array()) : void {
    $packageType = substr($vars['type'], strlen('bitrix') + 1);
    $localDir = explode('/', $vars['bitrix_dir']);
    array_pop($localDir);
    $localDir[] = 'local';
    $localDir = implode('/', $localDir);
    $oldPath = str_replace(array(
        '{$bitrix_dir}',
        '{$name}',
    ), array(
        $localDir,
        $vars['name'],
    ), $this->locations[$packageType]);
    if (in_array($oldPath, static::$checkedDuplicates)) {
        return;
    }
    if ($oldPath !== $path && file_exists($oldPath) && $this->io
        ->isInteractive()) {
        $this->io
            ->writeError('    <error>Duplication of packages:</error>');
        $this->io
            ->writeError('    <info>Package ' . $oldPath . ' will be called instead package ' . $path . '</info>');
        while (true) {
            switch ($this->io
                ->ask('    <info>Delete ' . $oldPath . ' [y,n,?]?</info> ', '?')) {
                case 'y':
                    $fs = new Filesystem();
                    $fs->removeDirectory($oldPath);
                    break 2;
                case 'n':
                    break 2;
                case '?':
                default:
                    $this->io
                        ->writeError(array(
                        '    y - delete package ' . $oldPath . ' and to continue with the installation',
                        '    n - don\'t delete and to continue with the installation',
                    ));
                    $this->io
                        ->writeError('    ? - print help');
                    break;
            }
        }
    }
    static::$checkedDuplicates[] = $oldPath;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal