Explorar el Código

Fixing ability to create heartposts

logicp hace 7 años
padre
commit
22c50e0357
Se han modificado 1 ficheros con 8 adiciones y 0 borrados
  1. 8 0
      src/StatusHeartPost.php

+ 8 - 0
src/StatusHeartPost.php

@@ -11,6 +11,8 @@ namespace Drupal\statusmessage;
 
 use Drupal\node\Entity\Node;
 use Drupal\taxonomy\Entity\Term;
+use Drupal\heartbeat\Entity\Heartbeat;
+
 
 /**
  * @property \Drupal\statusmessage\MarkupGenerator generator
@@ -157,6 +159,9 @@ class StatusHeartPost implements SharedContentInterface {
           ->execute();
 
         if (count($tid) > 0) {
+          if (\Drupal::moduleHandler()->moduleExists('heartbeat')) {
+            \Drupal\heartbeat\Entity\Heartbeat::updateTermUsage(array_values($tid)[0], 'tags');
+          }
           $tids[] = array_values($tid)[0];
         } else {
           $term = Term::create([
@@ -166,6 +171,9 @@ class StatusHeartPost implements SharedContentInterface {
           ]);
           if ($term->save()) {
             $tids[] = $term->id();
+            if (\Drupal::moduleHandler()->moduleExists('heartbeat')) {
+              \Drupal\heartbeat\Entity\Heartbeat::newTermUsage($term->id());
+            }
           }
         }
         $i++;