base-vui-button.php
110 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | namespace Jet_Form_Builder\Admin\Buttons; |
| 5 | |
| 6 | use Jet_Form_Builder\Classes\Arrayable\Arrayable; |
| 7 | |
| 8 | class Base_Vui_Button implements Arrayable { |
| 9 | |
| 10 | const STYLE_ACCENT = 'accent'; |
| 11 | const STYLE_DEFAULT = 'default'; |
| 12 | const STYLE_LINK_ACCENT = 'link-accent'; |
| 13 | const STYLE_LINK_ERROR = 'link-error'; |
| 14 | const STYLE_ACCENT_BORDER = 'accent-border'; |
| 15 | const STYLE_DEFAULT_BORDER = 'default-border'; |
| 16 | |
| 17 | const TYPE_BUTTON = 'button'; |
| 18 | const TYPE_SUBMIT = 'submit'; |
| 19 | const TYPE_RESET = 'reset'; |
| 20 | |
| 21 | const SIZE_DEFAULT = 'default'; |
| 22 | const SIZE_MINI = 'mini'; |
| 23 | const SIZE_LINK = 'link'; |
| 24 | |
| 25 | protected $slug = 'default'; |
| 26 | protected $url = ''; |
| 27 | protected $style = self::STYLE_ACCENT; |
| 28 | protected $type = self::TYPE_BUTTON; |
| 29 | protected $size = self::SIZE_DEFAULT; |
| 30 | protected $label = ''; |
| 31 | |
| 32 | public function __construct( string $slug ) { |
| 33 | $this->slug = $slug; |
| 34 | } |
| 35 | |
| 36 | /** Getters */ |
| 37 | |
| 38 | public function get_slug(): string { |
| 39 | return $this->slug; |
| 40 | } |
| 41 | |
| 42 | public function get_style(): string { |
| 43 | return $this->style; |
| 44 | } |
| 45 | |
| 46 | public function get_type(): string { |
| 47 | return $this->type; |
| 48 | } |
| 49 | |
| 50 | public function get_size(): string { |
| 51 | return $this->size; |
| 52 | } |
| 53 | |
| 54 | public function get_url(): string { |
| 55 | return $this->url; |
| 56 | } |
| 57 | |
| 58 | public function get_label(): string { |
| 59 | return $this->label; |
| 60 | } |
| 61 | |
| 62 | /** Setters */ |
| 63 | |
| 64 | public function set_style( string $style ): Base_Vui_Button { |
| 65 | $this->style = $style; |
| 66 | |
| 67 | return $this; |
| 68 | } |
| 69 | |
| 70 | public function set_type( string $type ): Base_Vui_Button { |
| 71 | $this->type = $type; |
| 72 | |
| 73 | return $this; |
| 74 | } |
| 75 | |
| 76 | public function set_size( string $size ): Base_Vui_Button { |
| 77 | $this->size = $size; |
| 78 | |
| 79 | return $this; |
| 80 | } |
| 81 | |
| 82 | public function set_url( string $url ): Base_Vui_Button { |
| 83 | $this->url = $url; |
| 84 | |
| 85 | return $this; |
| 86 | } |
| 87 | |
| 88 | public function set_label( string $label ): Base_Vui_Button { |
| 89 | $this->label = $label; |
| 90 | |
| 91 | return $this; |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * Get the instance as an array. |
| 96 | * |
| 97 | * @return array |
| 98 | */ |
| 99 | public function to_array(): array { |
| 100 | return array( |
| 101 | 'slug' => $this->get_slug(), |
| 102 | 'size' => $this->get_size(), |
| 103 | 'style' => $this->get_style(), |
| 104 | 'type' => $this->get_type(), |
| 105 | 'url' => $this->get_url(), |
| 106 | 'label' => $this->get_label(), |
| 107 | ); |
| 108 | } |
| 109 | } |
| 110 |