| 1 |
<?php |
| 2 |
/** |
| 3 |
* REST API: Gutenberg_REST_View_Config_Controller_7_2 class |
| 4 |
* |
| 5 |
* @package gutenberg |
| 6 |
*/ |
| 7 |
|
| 8 |
/** |
| 9 |
* Controller which provides a REST endpoint for retrieving the default |
| 10 |
* view configuration for a given entity type. |
| 11 |
* |
| 12 |
* Extends the 7.1 controller to describe the table column styles in the |
| 13 |
* item schema and to add the `showPlaceholderIfEmpty` option of the panel |
| 14 |
* form layout. |
| 15 |
* |
| 16 |
* @since 7.2.0 |
| 17 |
* |
| 18 |
* @see Gutenberg_REST_View_Config_Controller_7_1 |
| 19 |
*/ |
| 20 |
class Gutenberg_REST_View_Config_Controller_7_2 extends Gutenberg_REST_View_Config_Controller_7_1 { |
| 21 |
|
| 22 |
/** |
| 23 |
* Returns the schema for the ColumnStyle type. |
| 24 |
* |
| 25 |
* @since 7.2.0 Added descriptions to the column style properties. |
| 26 |
* |
| 27 |
* @return array Schema for a column style object. |
| 28 |
*/ |
| 29 |
protected function get_column_style_schema() { |
| 30 |
$schema = parent::get_column_style_schema(); |
| 31 |
|
| 32 |
$schema['properties']['width']['description'] = __( 'The width of the column.', 'gutenberg' ); |
| 33 |
$schema['properties']['maxWidth']['description'] = __( 'The maximum width of the column.', 'gutenberg' ); |
| 34 |
$schema['properties']['minWidth']['description'] = __( 'The minimum width of the column.', 'gutenberg' ); |
| 35 |
$schema['properties']['align']['description'] = __( 'The horizontal alignment of the column content.', 'gutenberg' ); |
| 36 |
|
| 37 |
return $schema; |
| 38 |
} |
| 39 |
|
| 40 |
/** |
| 41 |
* Returns the layout schema for table-type views (ViewTable, ViewPickerTable). |
| 42 |
* |
| 43 |
* @since 7.2.0 Added a description to the `styles` property. |
| 44 |
* |
| 45 |
* @return array Schema for a table layout object. |
| 46 |
*/ |
| 47 |
protected function get_table_layout_schema() { |
| 48 |
$schema = parent::get_table_layout_schema(); |
| 49 |
|
| 50 |
$schema['properties']['styles']['description'] = __( 'Column styles keyed by field id, for the columns listed in the view fields. The primary column (title, media, and description fields) ignores these styles; in the table layout it takes the width left over by the other columns, or the last column does when there is no primary column.', 'gutenberg' ); |
| 51 |
|
| 52 |
return $schema; |
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* Returns the schema for a form layout object. |
| 57 |
* |
| 58 |
* @since 7.2.0 Added the `showPlaceholderIfEmpty` property to the panel layout. |
| 59 |
* |
| 60 |
* @return array Schema for a form layout object. |
| 61 |
*/ |
| 62 |
protected function get_form_layout_schema() { |
| 63 |
$schema = parent::get_form_layout_schema(); |
| 64 |
|
| 65 |
foreach ( $schema['oneOf'] as $index => $layout ) { |
| 66 |
if ( array( 'panel' ) === $layout['properties']['type']['enum'] ) { |
| 67 |
$schema['oneOf'][ $index ]['properties']['showPlaceholderIfEmpty'] = array( |
| 68 |
'type' => 'boolean', |
| 69 |
); |
| 70 |
} |
| 71 |
} |
| 72 |
|
| 73 |
return $schema; |
| 74 |
} |
| 75 |
} |
| 76 |
|