Field.php
1 week ago
FieldInterface.php
1 week ago
Fields.php
1 week ago
FieldsInterface.php
1 week ago
Integrator.php
1 week ago
IntegratorIntegration.php
1 week ago
IntegratorInterface.php
1 week ago
Section.php
1 week ago
SectionInterface.php
1 week ago
Sections.php
1 week ago
SectionsInterface.php
1 week ago
Value.php
1 week ago
ValueInterface.php
1 week ago
Field.php
80 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WPDesk\FCF\Free\Integration; |
| 4 | |
| 5 | /** |
| 6 | * . |
| 7 | */ |
| 8 | class Field implements FieldInterface { |
| 9 | |
| 10 | /** |
| 11 | * Settings of field. |
| 12 | * |
| 13 | * @var array |
| 14 | */ |
| 15 | private $field_data; |
| 16 | |
| 17 | /** |
| 18 | * Key of field group. |
| 19 | * |
| 20 | * @var string |
| 21 | */ |
| 22 | private $field_group; |
| 23 | |
| 24 | /** |
| 25 | * Class constructor. |
| 26 | * |
| 27 | * @param array $field_data Settings of field. |
| 28 | * @param string $field_group Key of field group. |
| 29 | */ |
| 30 | public function __construct( array $field_data, string $field_group ) { |
| 31 | $this->field_data = $field_data; |
| 32 | $this->field_group = $field_group; |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Returns key of field. |
| 37 | * |
| 38 | * @return string Field key. |
| 39 | */ |
| 40 | public function get_field_key(): string { |
| 41 | return $this->field_data['name']; |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Returns type of field. |
| 46 | * |
| 47 | * @return string Field type, if known. |
| 48 | */ |
| 49 | public function get_field_type(): string { |
| 50 | return $this->field_data['type'] ?? ''; |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Returns label of field. |
| 55 | * |
| 56 | * @return string Field label. |
| 57 | */ |
| 58 | public function get_field_label(): string { |
| 59 | return $this->field_data['label']; |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Returns status if field is custom. |
| 64 | * |
| 65 | * @return bool If field is custom? |
| 66 | */ |
| 67 | public function is_custom_field(): bool { |
| 68 | return ( isset( $this->field_data['custom_field'] ) && $this->field_data['custom_field'] ); |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * Returns key of field group. |
| 73 | * |
| 74 | * @return string Group key. |
| 75 | */ |
| 76 | public function get_group_key(): string { |
| 77 | return $this->field_group; |
| 78 | } |
| 79 | } |
| 80 |