public function RealisticDummyContentFileGroup::attribute in Realistic Dummy Content 3.x
Same name and namespace in other branches
- 8.2 api/src/includes/RealisticDummyContentFileGroup.php \Drupal\realistic_dummy_content_api\includes\RealisticDummyContentFileGroup::attribute()
- 7.2 api/src/includes/RealisticDummyContentFileGroup.php \Drupal\realistic_dummy_content_api\includes\RealisticDummyContentFileGroup::attribute()
Return the value for an attribute name if possible.
Parameters
string $name: The attribute name to fetch.
mixed $default: The default value.
Return value
mixed 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/ includes/ RealisticDummyContentFileGroup.php, line 163
Class
- RealisticDummyContentFileGroup
- Represents files as groups.
Namespace
Drupal\realistic_dummy_content_api\includesCode
public function attribute($name, $default = NULL) {
try {
$attributes = $this
->getAttributes();
if (isset($attributes[$name]->uri)) {
$return = trim(RealisticDummyContentEnvironment::get()
->fileGetContents($attributes[$name]->uri));
return $return;
}
else {
return $default;
}
} catch (\Throwable $e) {
return $default;
}
}