public static function ProblemsStorage::replace_problem_stats in Node Accessibility 8
Insert or Update accessibility problem stats.
Parameters
int $uid: The user account id associated with the stat.
int $nid: The node id.
int $vid: The node revision id.
int $timestamp: The unix timestamp for the stat.
Return value
bool TRUE on success, FALSE otherwise.
1 call to ProblemsStorage::replace_problem_stats()
- ProblemsStorage::save_node_problems in src/
ProblemsStorage.php - Saves the node report data to the database.
File
- src/
ProblemsStorage.php, line 679
Class
- ProblemsStorage
- Class DatabaseStorage.
Namespace
Drupal\node_accessibilityCode
public static function replace_problem_stats($uid, $nid, $vid, $timestamp) {
if (!is_int($uid) || !is_int($nid) || !is_int($vid) || !is_int($timestamp)) {
return FALSE;
}
$result = FALSE;
$transaction = \Drupal::database()
->startTransaction();
try {
$query = \Drupal::database()
->delete('node_accessibility_stats');
$query
->condition('nid', $nid);
$query
->condition('vid', $vid);
$query
->execute();
$data['uid'] = $uid;
$data['nid'] = $nid;
$data['vid'] = $vid;
$data['timestamp'] = $timestamp;
$result = \Drupal::database()
->insert('node_accessibility_stats')
->fields($data)
->execute();
} catch (Exception $e) {
$transaction
->rollback();
\Drupal::logger('node_accessibility')
->error("Failed to replace accessibility validation stats for nid=@nid, vid=@vid.", [
'@nid' => $nid,
'@vid' => $vid,
]);
return FALSE;
} catch (Error $e) {
$transaction
->rollback();
\Drupal::logger('node_accessibility')
->error("Failed to replace accessibility validation stats for nid=@nid, vid=@vid.", [
'@nid' => $nid,
'@vid' => $vid,
]);
return FALSE;
}
return $result;
}