TemplateCreator.php in Heartbeat 8
File
modules/statusmessage/src/TemplateCreator.php
View source
<?php
namespace Drupal\statusmessage;
class TemplateCreator {
protected $markup;
protected $images;
protected $imageMarkup;
protected $title;
protected $description;
public function generateImage($image) {
$this->images[] = '<img class="statusmessage-image" src="' . $image . '"/ >"';
}
public function generateTitle($title) {
$this->title = '<h3 class="statusmessage-title">' . $title . '</h3>';
}
public function generateDescription($description) {
$this->description = '<p class="statusmessage-description">' . $description . '</p>';
}
private function generateImageMarkup() {
foreach ($this->images as $image) {
$this->imageMarkup .= $image;
}
}
public function getPreview() {
if ($this->imageMarkup === null) {
$this
->generateImageMarkup();
}
return $this
->wrap($this->title . $this->description . $this->imageMarkup);
}
private function wrap($string) {
return '<div class="statusmessage-preview">' . $string . '</div>';
}
}