public static function Updater::findInfoFile

public static Updater::findInfoFile($directory)

Determines what the most important (or only) info file is in a directory.

Since there is no enforcement of which info file is the project's "main" info file, this will get one with the same name as the directory, or the first one it finds. Not ideal, but needs a larger solution.

Parameters

string $directory: Directory to search in.

Return value

string Path to the info file.

File

core/lib/Drupal/Core/Updater/Updater.php, line 109

Class

Updater
Defines the base class for Updaters used in Drupal.

Namespace

Drupal\Core\Updater

Code

public static function findInfoFile($directory) {
  $info_files = file_scan_directory($directory, '/.*\.info.yml$/');
  if (!$info_files) {
    return FALSE;
  }
  foreach ($info_files as $info_file) {
    if (Unicode::substr($info_file->filename, 0, -9) == drupal_basename($directory)) {
      // Info file Has the same name as the directory, return it.
      return $info_file->uri;
    }
  }
  // Otherwise, return the first one.
  $info_file = array_shift($info_files);
  return $info_file->uri;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Updater!Updater.php/function/Updater::findInfoFile/8.1.x