summaryrefslogtreecommitdiff
path: root/src/Controllers/FieldsController.php
blob: 3725463d535adf3d030992ae3df5ac26a6e6c7dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php

namespace FlatFileForms\Controllers;

use FlatFileForms\Builder;
use FlatFileForms\Utilities;

class FieldsController
{
  public function getFields(Builder $builder): array
  {
    /**@var Utilities $utilities*/
    global $utilities;

    $fields = $builder->buildFields($_GET['page'] ?? null);

    // flatten paged form
    if ($utilities->isPagedFieldSet($fields) && isset($_GET['flat'])) {
      $fields = array_merge(...array_values($fields));
    }

    $content['data'] = $fields;

    return $content;
  }
}