Lines Matching refs:def
120 foreach ((array) $raw as $def) {
121 $def = $this->normaliseDefinition($def);
122 if ($def === null) {
125 if (isset($toggles[$def['key']])) {
128 $toggles[$def['key']] = $def;
161 * @param mixed $def
164 protected function normaliseDefinition($def) argument
166 if (!is_array($def)) return null;
167 if (empty($def['key']) || !is_string($def['key'])) return null;
168 if (empty($def['label']) || !is_string($def['label'])) return null;
171 if (!preg_match('/^[A-Za-z0-9_]+$/', $def['key'])) return null;
173 $type = $def['type'] ?? 'checkbox';
179 'key' => $def['key'],
180 'label' => $def['label'],
182 'desc' => (isset($def['desc']) && is_string($def['desc'])) ? $def['desc'] : '',
183 'plugin' => (isset($def['plugin']) && is_string($def['plugin'])) ? $def['plugin'] : '',
188 if (empty($def['options']) || !is_array($def['options'])) {
191 $clean['options'] = $def['options'];
193 $default = $def['default'] ?? null;
194 if ($default === null || !array_key_exists($default, $def['options'])) {
195 $default = array_key_first($def['options']);
200 $clean['default'] = empty($def['default']) ? 0 : 1;