You are here

function FileGroup::Attribute in Realistic Dummy Content 8

Return the value for an attribute name if possible

Parameters

$name: The attribute name to fetch

$default:

Return value

The default value if the attribute does not exist, if it's empty or if an error occurred, otherwise the contents of the attributes file.

File

api/src/environments/FileGroup.php, line 156
Define autoload class.

Class

FileGroup
Represents files as groups.

Namespace

Drupal\realistic_dummy_content_api\environments

Code

function Attribute($name, $default = NULL) {
  try {
    $attributes = $this
      ->GetAttributes();
    if (isset($attributes[$name]->uri)) {
      $return = trim(Environment::Get()
        ->file_get_contents($attributes[$name]->uri));
      return $return;
    }
    else {
      return $default;
    }
  } catch (\Exception $e) {
    return $default;
  }
}