PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 2.23.0
GiveWP – Donation Plugin and Fundraising Platform v2.23.0
4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 All 253 releases
give / src / Framework / FieldsAPI / Field.php

Field.php in GiveWP – Donation Plugin and Fundraising Platform 2.23.0, at src/Framework/FieldsAPI/Field.php

75 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\Framework\FieldsAPI;
4
5 use Give\Framework\FieldsAPI\Concerns\ValidationRules;
6 use Give\Framework\FieldsAPI\Contracts\Node;
7 use Give\Framework\FieldsAPI\Exceptions\EmptyNameException;
8
9 /**
10 * @since 2.17.0 allow fields to be macroable
11 * @since 2.12.0
12 * @since 2.13.0 Support visibility conditions
13 * @since 2.22.0 Add TapNode trait
14 */
15 abstract class Field implements Node
16 {
17
18 use Concerns\HasDefaultValue;
19 use Concerns\HasName;
20 use Concerns\HasType;
21 use Concerns\HasVisibilityConditions;
22 use Concerns\IsReadOnly;
23 use Concerns\IsRequired;
24 use Concerns\Macroable;
25 use Concerns\SerializeAsJson;
26 use Concerns\TapNode;
27
28 /** @var ValidationRules */
29 protected $validationRules;
30
31 /**
32 * @since 2.12.0
33 *
34 * @param string $name
35 *
36 * @throws EmptyNameException
37 */
38 public function __construct($name)
39 {
40 if (!$name) {
41 throw new EmptyNameException();
42 }
43
44 $this->name = $name;
45 $this->validationRules = new ValidationRules();
46 }
47
48 /**
49 * @inheritDoc
50 */
51 public function getNodeType(): string
52 {
53 return 'field';
54 }
55
56 /**
57 * Create a named field.
58 *
59 * @since 2.12.0
60 *
61 * @param string $name
62 *
63 * @return static
64 * @throws EmptyNameException
65 */
66 public static function make($name)
67 {
68 if (!$name) {
69 throw new EmptyNameException();
70 }
71
72 return new static($name);
73 }
74 }
75