File "PostListTransformer.php"

Full Path: /home/warrior1/public_html/wp-content-20241001222009/plugins/mailpoet/lib/Newsletter/Editor/PostListTransformer.php
File size: 678 bytes
MIME-type: text/x-php
Charset: utf-8

<?php

namespace MailPoet\Newsletter\Editor;

if (!defined('ABSPATH')) exit;


class PostListTransformer {

  private $args;
  private $transformer;

  public function __construct(
    $args
  ) {
    $this->args = $args;
    $this->transformer = new PostTransformer($args);
  }

  public function transform($posts) {
    $results = [];
    $useDivider = filter_var($this->args['showDivider'], FILTER_VALIDATE_BOOLEAN);

    foreach ($posts as $index => $post) {
      if ($useDivider && $index > 0) {
        $results[] = $this->transformer->getDivider();
      }

      $results = array_merge($results, $this->transformer->transform($post));
    }

    return $results;
  }
}