Jake Vanderwerf
2026-01-01 de699440ff94e9c0d8e8b5201ee93179c085bf60
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
 
namespace JVBase\managers\SEO;
 
 
/**
 * Field Builder - Fluent API for field definitions
 */
class FieldBuilder
{
    private SchemaBuilder $schema;
    private string $name;
    private array $definition = [];
 
    public function __construct(SchemaBuilder $schema, string $name, array $baseDefinition = [])
    {
        $this->schema = $schema;
        $this->name = $name;
        $this->definition = $baseDefinition;
    }
 
    public function type(string $type): self
    {
        $this->definition['type'] = $type;
        return $this;
    }
 
    public function label(string $label): self
    {
        $this->definition['label'] = $label;
        return $this;
    }
 
    public function description(string $description): self
    {
        $this->definition['description'] = $description;
        return $this;
    }
 
    public function transformer(string $transformer): self
    {
        $this->definition['transformer'] = $transformer;
        return $this;
    }
 
    public function required(bool $required = true): self
    {
        $this->definition['required'] = $required;
        return $this;
    }
 
    public function repeater(bool $repeater = true): self
    {
        $this->definition['repeater'] = $repeater;
        return $this;
    }
 
    public function options(array $options): self
    {
        $this->definition['options'] = $options;
        return $this;
    }
 
    public function placeholder(string $placeholder): self
    {
        $this->definition['placeholder'] = $placeholder;
        return $this;
    }
 
    public function fields(array $fields): self
    {
        $this->definition['fields'] = $fields;
        return $this;
    }
 
    public function default($default): self
    {
        $this->definition['default'] = $default;
        return $this;
    }
 
    /**
     * Finish building and register the field
     */
    public function __destruct()
    {
        $this->schema->registerField($this->name, $this->definition);
    }
}