1 | <?php |
||
5 | abstract class AbstractWidget extends \WP_Widget |
||
6 | { |
||
|
|||
7 | /** |
||
8 | * @var array The configuration array |
||
9 | */ |
||
10 | private $config; |
||
11 | |||
12 | /** |
||
13 | * @var \Amarkal\UI\Form Amarkal UI for data processing |
||
14 | */ |
||
15 | private $ui_form; |
||
16 | |||
17 | /** |
||
18 | * Get the user config and call the parent constructor |
||
19 | */ |
||
20 | public function __construct() |
||
31 | |||
32 | /** |
||
33 | * Generates the administration form for the widget |
||
34 | * |
||
35 | * @param array $instance The array of keys and values for the widget |
||
36 | */ |
||
37 | public function form( $instance ) |
||
61 | |||
62 | /** |
||
63 | * Process the widget's options before they are saved into the db |
||
64 | * |
||
65 | * @param array $new_instance The previous instance of values before the update. |
||
66 | * @param array $old_instance The new instance of values to be generated via the update. |
||
67 | */ |
||
68 | public function update( $new_instance, $old_instance ) |
||
73 | |||
74 | /** |
||
75 | * Get the Amarkal UI form. |
||
76 | * |
||
77 | * @return \Amarkal\UI\Form |
||
78 | */ |
||
79 | private function get_form() |
||
88 | |||
89 | /** |
||
90 | * Get the default widget configuration. |
||
91 | * |
||
92 | * @return array |
||
93 | */ |
||
94 | private function default_config() |
||
104 | |||
105 | /** |
||
106 | * Get the configuraiton array, merging between the user and the default |
||
107 | * configuration values. |
||
108 | * |
||
109 | * @return array |
||
110 | * @throws \RuntimeException if the configuration is missing the ID argument |
||
111 | */ |
||
112 | private function get_config() |
||
128 | |||
129 | /** |
||
130 | * The user configuration array. Must be implemented in the child class. |
||
131 | */ |
||
132 | abstract public function config(); |
||
133 | } |