Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d8 / hook / node_search_result.twig
diff --git a/vendor/chi-teck/drupal-code-generator/templates/d8/hook/node_search_result.twig b/vendor/chi-teck/drupal-code-generator/templates/d8/hook/node_search_result.twig
new file mode 100644 (file)
index 0000000..362e21f
--- /dev/null
@@ -0,0 +1,7 @@
+/**
+ * Implements hook_node_search_result().
+ */
+function {{ machine_name }}_node_search_result(\Drupal\node\NodeInterface $node) {
+  $rating = db_query('SELECT SUM(points) FROM {my_rating} WHERE nid = :nid', ['nid' => $node->id()])->fetchField();
+  return ['rating' => \Drupal::translation()->formatPlural($rating, '1 point', '@count points')];
+}