Explorar el Código

Updating StatusForm to only create HeartbeatPost descriptions that are 255 characters max length

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

+ 7 - 8
src/StatusHeartPost.php

@@ -79,10 +79,8 @@ class StatusHeartPost implements SharedContentInterface {
     }
 
     return $this->generator->getTags();
-
   }
 
-
   private function setNodeData() {
 
     $append = FALSE;
@@ -93,16 +91,17 @@ class StatusHeartPost implements SharedContentInterface {
       'status' => 1,
     ]);
 
+    $description = strlen($this->generator->getDescription()) <= 207 ? $this->generator->getDescription() : substr($this->generator->getDescription(), 0, 206);
 
-    if (strlen($this->generator->getDescription()) <= 255) {
-      $node->set('field_description', [
-        'value' => '<div class="status-heartpost-description"> ' . $this->generator->getDescription() . '</div>',
-        'format' => 'full_html'
-      ]);
-    } else {
+    if (strlen($this->generator->getDescription()) > 207) {
       $append = TRUE;
     }
 
+    $node->set('field_description', [
+      'value' => '<div class="status-heartpost-description"> ' . $description . '</div>',
+      'format' => 'full_html'
+    ]);
+
     if ($this->message) {
       $this->message = $append ? $this->message . ' ' . PHP_EOL . $this->generator->getDescription() : $this->message;