You are here

public static function HudtInternal::readFileToArray in Hook Update Deploy Tools 8

Same name and namespace in other branches
  1. 7 src/HudtInternal.php \HookUpdateDeployTools\HudtInternal::readFileToArray()

Read the contents of a file into an array of one element per line.

Parameters

string $filename: The filename of the file.

string $storage_type: The type of storage (menu, panel, rule...).

Return value

array One element per line.

File

src/HudtInternal.php, line 57

Class

HudtInternal
Methods for processes internal to Hook Deploy Update Tools.

Namespace

HookUpdateDeployTools

Code

public static function readFileToArray($filename, $storage_type) {
  $path = self::getStoragePath($storage_type);
  $file = "{$path}{$filename}";
  if (self::canReadFile($filename, $storage_type)) {

    // Get the contents as an array.
    $file_contents = file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
  }
  else {

    // Should not reach here due to exception from canReadFile.
    $file_contents = array();
  }
  return $file_contents;
}