Exceptions
1 year ago
PaymentsProviders
3 months ago
SettingsUIPages
4 weeks ago
LegacySettingsPageAdapter.php
4 weeks ago
Payments.php
3 months ago
PaymentsController.php
11 months ago
PaymentsProviders.php
2 months ago
PaymentsRestController.php
3 months ago
RegisteredSettingsSectionAdapter.php
2 weeks ago
SettingsUIPageInterface.php
4 weeks ago
SettingsUIRequestContext.php
2 weeks ago
SettingsUISchema.php
2 weeks ago
Utils.php
2 months ago
RegisteredSettingsSectionAdapter.php
61 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Registered settings section adapter for settings UI. |
| 4 | */ |
| 5 | |
| 6 | declare( strict_types=1 ); |
| 7 | |
| 8 | namespace Automattic\WooCommerce\Internal\Admin\Settings; |
| 9 | |
| 10 | use Automattic\WooCommerce\Admin\Settings\SettingsSectionInterface; |
| 11 | |
| 12 | defined( 'ABSPATH' ) || exit; |
| 13 | |
| 14 | /** |
| 15 | * Adapts a registered settings section into the settings UI page contract. |
| 16 | * |
| 17 | * @since 10.9.0 |
| 18 | */ |
| 19 | class RegisteredSettingsSectionAdapter extends LegacySettingsPageAdapter { |
| 20 | |
| 21 | /** |
| 22 | * Registered settings section. |
| 23 | * |
| 24 | * @var SettingsSectionInterface |
| 25 | */ |
| 26 | private SettingsSectionInterface $section; |
| 27 | |
| 28 | /** |
| 29 | * Constructor. |
| 30 | * |
| 31 | * @since 10.9.0 |
| 32 | * |
| 33 | * @param \WC_Settings_Page $settings_page Parent settings page. |
| 34 | * @param SettingsSectionInterface $section Registered settings section. |
| 35 | */ |
| 36 | public function __construct( \WC_Settings_Page $settings_page, SettingsSectionInterface $section ) { |
| 37 | parent::__construct( $settings_page ); |
| 38 | $this->section = $section; |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Get script handles that must be loaded before the settings UI app mounts. |
| 43 | * |
| 44 | * @param string $section Unused. This adapter wraps a single registered section. |
| 45 | * @return string[] |
| 46 | */ |
| 47 | public function get_script_handles( string $section ): array { |
| 48 | return $this->section->get_script_handles( $this->settings_page ); |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Get the default save adapter for fields in this section. |
| 53 | * |
| 54 | * @param string $section Unused. This adapter wraps a single registered section. |
| 55 | * @return string |
| 56 | */ |
| 57 | public function get_save_adapter( string $section ): string { |
| 58 | return $this->section->get_save_adapter( $this->settings_page ); |
| 59 | } |
| 60 | } |
| 61 |