Component.php
2 years ago
ComponentTrait.php
3 years ago
Field.php
3 years ago
FormFactory.php
3 years ago
Section.php
3 years ago
Subsection.php
3 years ago
Tab.php
3 years ago
Tab.php
48 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Handles product form tab related methods. |
| 4 | */ |
| 5 | |
| 6 | namespace Automattic\WooCommerce\Internal\Admin\ProductForm; |
| 7 | |
| 8 | /** |
| 9 | * Field class. |
| 10 | */ |
| 11 | class Tab extends Component { |
| 12 | |
| 13 | /** |
| 14 | * Constructor |
| 15 | * |
| 16 | * @param string $id Field id. |
| 17 | * @param string $plugin_id Plugin id. |
| 18 | * @param array $additional_args Array containing the necessary arguments. |
| 19 | * $args = array( |
| 20 | * 'name' => (string) Tab name. Required. |
| 21 | * 'title' => (string) Tab title. Required. |
| 22 | * 'order' => (int) Tab order. |
| 23 | * 'properties' => (array) Tab properties. |
| 24 | * ). |
| 25 | * @throws \Exception If there are missing arguments. |
| 26 | */ |
| 27 | public function __construct( $id, $plugin_id, $additional_args ) { |
| 28 | parent::__construct( $id, $plugin_id, $additional_args ); |
| 29 | |
| 30 | $this->required_arguments = array( |
| 31 | 'name', |
| 32 | 'title', |
| 33 | ); |
| 34 | |
| 35 | $missing_arguments = self::get_missing_arguments( $additional_args ); |
| 36 | if ( count( $missing_arguments ) > 0 ) { |
| 37 | throw new \Exception( |
| 38 | sprintf( |
| 39 | /* translators: 1: Missing arguments list. */ |
| 40 | esc_html__( 'You are missing required arguments of WooCommerce ProductForm Tab: %1$s', 'woocommerce' ), |
| 41 | join( ', ', $missing_arguments ) |
| 42 | ) |
| 43 | ); |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | } |
| 48 |