You are here

function RealisticDummyContentFileGroup::Attribute in Realistic Dummy Content 7

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/includes/RealisticDummyContentFileGroup.inc, line 151
Define RealisticDummyContentFileGroup autoload class.

Class

RealisticDummyContentFileGroup
Represents files as groups.

Code

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