You are here

public function DeprecationAnalyzer::initEnvironment in Upgrade Status 8.3

Same name and namespace in other branches
  1. 8.2 src/DeprecationAnalyzer.php \Drupal\upgrade_status\DeprecationAnalyzer::initEnvironment()

Initialize the external environment.

Throws

\Exception In case initialization failed. The analyzer will not work in this case.

1 call to DeprecationAnalyzer::initEnvironment()
DeprecationAnalyzer::analyze in src/DeprecationAnalyzer.php
Analyze the codebase of an extension including all its sub-components.

File

src/DeprecationAnalyzer.php, line 164

Class

DeprecationAnalyzer

Namespace

Drupal\upgrade_status

Code

public function initEnvironment() {
  if (!empty($this->environmentInitialized)) {

    // Already successfully initialized, no need to do it again.
    return;
  }
  $this->finder = new DrupalFinder();
  $this->finder
    ->locateRoot(DRUPAL_ROOT);
  $this->vendorPath = $this->finder
    ->getVendorDir();
  $this->binPath = $this
    ->findBinPath();
  if (function_exists('file_directory_temp')) {

    // This is fallback code for 8.7.x and below. It's not called on later
    // versions, so we don't nee to "fix" it.
    // @noRector
    // @phpstan-ignore-next-line
    $system_temporary = file_directory_temp();
  }
  else {
    $system_temporary = $this->fileSystem
      ->getTempDirectory();
  }
  $this->temporaryDirectory = $system_temporary . '/upgrade_status';
  if (!file_exists($this->temporaryDirectory)) {
    $this
      ->prepareTempDirectory();
  }
  $this->phpstanNeonPath = $this->temporaryDirectory . '/deprecation_testing.neon';
  $this
    ->createModifiedNeonFile();
  $this->environmentInitialized = TRUE;
}