You are here

private function DebuggingReviewForm::parsePhpModules in Lightweight Directory Access Protocol (LDAP) 8.4

Generates an array of values from phpinfo().

Return value

array Module list.

File

ldap_servers/src/Form/DebuggingReviewForm.php, line 200

Class

DebuggingReviewForm
Form to allow for debugging review.

Namespace

Drupal\ldap_servers\Form

Code

private function parsePhpModules() : array {
  ob_start();
  phpinfo(INFO_MODULES);
  $output = ob_get_clean();
  $output = strip_tags($output, '<h2><th><td>');
  $output = preg_replace('/<th[^>]*>([^<]+)<\\/th>/', "<info>\\1</info>", $output);
  $output = preg_replace('/<td[^>]*>([^<]+)<\\/td>/', "<info>\\1</info>", $output);

  /** @var string[] $rows */
  $rows = preg_split('/(<h2>[^<]+<\\/h2>)/', $output, -1, PREG_SPLIT_DELIM_CAPTURE);
  $modules = [];
  if (is_array($rows)) {
    $rowCount = count($rows);

    // First line with CSS can be ignored.
    for ($i = 1; $i < $rowCount - 1; $i++) {
      $this
        ->extractModule($rows[$i], $rows[$i + 1], $modules);
    }
  }
  return $modules;
}