You are here

class ForumTopicRender in Opigno forum 3.x

Forum topic render helper class.

Hierarchy

Expanded class hierarchy of ForumTopicRender

1 file declares its use of ForumTopicRender
opigno_forum.module in ./opigno_forum.module
Contains opigno_forum.module.

File

src/ForumTopicRender.php, line 8

Namespace

Drupal\opigno_forum
View source
class ForumTopicRender {

  /**
   * Prepares variables for opigno_forum_last_topics_block template.
   */
  public function preprocessForumLastTopicsBlock(array &$variables) : void {
    foreach ($variables["elements"]["topics"] as $index => $topic) {
      $variables["elements"]["topics"][$index] = [
        '#theme' => 'opigno_forum_last_topics_item',
        '#topic' => $topic,
      ];
    }
  }

  /**
   * Prepares variables for opigno_forum_last_topics_item template.
   *
   * @throws \Drupal\Core\Entity\EntityMalformedException
   */
  public function preprocessForumLastTopicsItem(array &$variables) : void {

    /** @var \Drupal\node\Entity\Node $topic */
    $topic =& $variables["topic"];
    $variables['name'] = $topic
      ->label();
    $variables['link'] = $topic
      ->toUrl()
      ->toString();
    $variables['new_posts'] = $topic->new_replies;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ForumTopicRender::preprocessForumLastTopicsBlock public function Prepares variables for opigno_forum_last_topics_block template.
ForumTopicRender::preprocessForumLastTopicsItem public function Prepares variables for opigno_forum_last_topics_item template.