public static function TypeSettingsStorage::loadByNode in Node Accessibility 8
Loads the node accessibility node type settings for a specific node.
If nodeType does not exist or there is an error, then the value will be set to NULL.
Parameters
int $nid: The numeric node id.
Return value
array An array of node type settings. This always returns a populated array. On error or invalid data, the default settings are returned.
2 calls to TypeSettingsStorage::loadByNode()
- ValidateFormBase::buildForm in src/
Form/ ValidateFormBase.php - Form constructor.
- ValidateFormBase::submitForm in src/
Form/ ValidateFormBase.php - Form submission handler.
File
- src/
TypeSettingsStorage.php, line 208
Class
- TypeSettingsStorage
- Class TypeSettingsStorage.
Namespace
Drupal\node_accessibilityCode
public static function loadByNode($nid) {
$node_type = NULL;
try {
$query = \Drupal::database()
->select('node', 'n');
$query
->addField('n', 'type', 'node_type');
$query
->condition('n.nid', $nid);
$existing = $query
->execute()
->fetchObject();
if ($existing) {
$node_type = $existing->node_type;
}
} catch (Exception $e) {
\Drupal::logger('node_accessibility')
->error("Failed to select from {node} table, exception: @exception.", [
'@exception' => $e
->getMessage(),
]);
} catch (Error $e) {
\Drupal::logger('node_accessibility')
->error("Failed to select from {node} table, exception: @exception.", [
'@exception' => $e
->getMessage(),
]);
}
return static::load($node_type);
}