You are here

protected function PackageManager::jsonRead in Ludwig 8

Reads and decodes a json file into an array.

Parameters

string $filename: Name of the file to read.

Return value

array The decoded json data.

1 call to PackageManager::jsonRead()
PackageManager::getPackages in src/PackageManager.php
Gets the ludwig-managed packages.

File

src/PackageManager.php, line 215

Class

PackageManager
Provides information about ludwig-managed packages.

Namespace

Drupal\ludwig

Code

protected function jsonRead($filename) {
  $data = [];
  if (file_exists($filename)) {
    $data = file_get_contents($filename);
    $data = json_decode($data, TRUE);
    if (!$data) {
      $data = [];
    }
  }
  return $data;
}