Changeset 3474817
- Timestamp:
- 03/04/2026 06:09:08 PM (4 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
admin-menu-editor/trunk/customizables/Builders/ElementBuilderFactory.php
r3400590 r3474817 217 217 } else if ( $setting instanceof Settings\NumericSetting ) { 218 218 return $this->number($setting); 219 } else if ( $setting instanceof Settings\PredefinedSet ) { 220 return $this->autoSection($setting); 219 } else if ( $setting instanceof Settings\ControlGenerator ) { 220 221 $controls = $setting->createControls($this); 222 if ( count($controls) === 1 ) { 223 //If there's only one control, just return it directly. We don't need a new section. 224 return reset($controls); 225 } else { 226 //Create a section that contains the controls. 227 return $this->section($setting->getLabel(), ...$controls) 228 ->params(['preferredRole' => Controls\Section::CONTENT_ROLE]); 229 } 230 221 231 } else if ( $setting instanceof Settings\WithSchema\SingularSetting ) { 222 232 … … 235 245 } else if ( $schema instanceof Schemas\Number ) { 236 246 return $this->number($setting); 237 } else { 238 return $this->textBox($setting); 239 } 240 241 } else if ( $setting instanceof Settings\AbstractSetting ) { 247 } 248 } 249 250 //Turn general structs into sections. (Composite settings are excluded because they usually 251 //need custom handling; their children don't make sense as independent controls.) 252 if ( 253 ($setting instanceof Settings\AbstractStructSetting) 254 && !($setting instanceof Settings\CompositeSetting) 255 ) { 256 return $this->autoSection($setting); 257 } 258 259 if ( $setting instanceof Settings\AbstractSetting ) { 242 260 switch ($setting->getDataType()) { 243 261 case 'color': … … 276 294 277 295 $firstSetting = reset($settings); 278 if ( $firstSetting instanceof Settings\ PredefinedSet) {296 if ( $firstSetting instanceof Settings\ControlGenerator ) { 279 297 $controls = $firstSetting->createControls($this); 280 298 return $this->section( … … 282 300 ...$controls 283 301 )->params(['preferredRole' => $role]); 302 } 303 304 //Handle simple structs. 305 if ( 306 (count($settings) === 1) 307 && ($firstSetting instanceof Settings\AbstractStructSetting) 308 && !($firstSetting instanceof Settings\CompositeSetting) 309 ) { 310 $section = $this->section($title ?: $firstSetting->getLabel())->params(['preferredRole' => $role]); 311 foreach ($firstSetting as $setting) { 312 $section->add($this->auto($setting)); 313 } 314 return $section; 284 315 } 285 316
Note: See TracChangeset
for help on using the changeset viewer.