private function StatusHeartPost::setNodeData in Heartbeat 8
1 call to StatusHeartPost::setNodeData()
- StatusHeartPost::sendRequest in modules/
statusmessage/ src/ StatusHeartPost.php
File
- modules/
statusmessage/ src/ StatusHeartPost.php, line 84
Class
- StatusHeartPost
- @property \Drupal\statusmessage\MarkupGenerator generator @property message
Namespace
Drupal\statusmessageCode
private function setNodeData() {
$append = FALSE;
$title = $this->generator
->getTitle();
$node = Node::create([
'type' => 'heartpost',
'title' => strlen($title) < 50 ? $title : substr($title, 0, 47) . '...',
'status' => 1,
]);
$description = strlen($this->generator
->getDescription()) <= 207 ? $this->generator
->getDescription() : substr($this->generator
->getDescription(), 0, 206);
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;
$node
->set('body', [
'value' => '<div class="status-heartpost"> ' . $this->message . ' </div>',
'format' => 'full_html',
]);
}
return $node;
}