PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.18
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.18
1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 1.10.1 1.10.0 1.9.17 1.9.15 1.9.16 1.9.14 1.9.13 All 162 releases
woocommerce-pos / includes / Services / Settings / Section_Registry.php

Section_Registry.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.10.18, at includes/Services/Settings/Section_Registry.php

71 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Section Registry.
4 *
5 * @package WCPOS\WooCommercePOS
6 */
7
8 namespace WCPOS\WooCommercePOS\Services\Settings;
9
10 use WCPOS\WooCommercePOS\Interfaces\Settings_Section_Interface;
11
12 /**
13 * The Section Registry — the seam where Settings Sections are registered.
14 *
15 * The free plugin registers its core sections; Pro and extensions register
16 * theirs via the `woocommerce_pos_register_settings_sections` action instead
17 * of hooking ad-hoc filters. Registering an existing id replaces the previous
18 * section (last-wins), which is also the supported override mechanism.
19 * Override sections should extend Abstract_Section (not implement the
20 * interface directly) so the typed accessors' default fallback
21 * (Settings::section_value()) keeps working.
22 */
23 class Section_Registry {
24 /**
25 * Registered sections, keyed by id.
26 *
27 * @var array<string, Settings_Section_Interface>
28 */
29 private $sections = array();
30
31 /**
32 * Register (or replace) a section.
33 *
34 * @param Settings_Section_Interface $section The section.
35 */
36 public function register( Settings_Section_Interface $section ): void {
37 $this->sections[ $section->id() ] = $section;
38 }
39
40 /**
41 * Get a section by id.
42 *
43 * @param string $id Section id.
44 *
45 * @return Settings_Section_Interface|null
46 */
47 public function get( string $id ): ?Settings_Section_Interface {
48 return $this->sections[ $id ] ?? null;
49 }
50
51 /**
52 * Whether a section is registered.
53 *
54 * @param string $id Section id.
55 *
56 * @return bool
57 */
58 public function has( string $id ): bool {
59 return isset( $this->sections[ $id ] );
60 }
61
62 /**
63 * All registered sections, keyed by id.
64 *
65 * @return array<string, Settings_Section_Interface>
66 */
67 public function all(): array {
68 return $this->sections;
69 }
70 }
71